From 7babddf4433658039057a73465370288d33b94b1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 29 Nov 2022 12:45:47 +0000 Subject: [PATCH 01/11] PMP: Replace parameter with named parameter --- .../triangulate_hole.h | 122 ++++++++++++++++-- .../internal/parameters_interface.h | 4 +- 2 files changed, 115 insertions(+), 11 deletions(-) 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 f246500b49a..7b0aa01149f 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 @@ -70,19 +70,25 @@ namespace Polygon_mesh_processing { must not intersect the surface. Otherwise, additionally, the boundary of the hole must not contain any non-manifold vertex. The patch generated does not introduce non-manifold edges nor degenerate triangles. If a hole cannot be triangulated, - `pmesh` is not modified and nothing is recorded in `out`. + `pmesh` is not modified and nothing is recorded in the face output + iterator. @tparam PolygonMesh a model of `MutableFaceGraph` - @tparam OutputIterator a model of `OutputIterator` - holding `boost::graph_traits::%face_descriptor` for patch faces. @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @param pmesh polygon mesh containing the hole @param border_halfedge a border halfedge incident to the hole - @param out iterator over patch faces @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below \cgalNamedParamsBegin + + \cgalParamNBegin{face_output_iterator_t} + \cgalParamDescription{iterator over patch faces} + \cgalParamType{a model of `OutputIterator` + holding `boost::graph_traits::%face_descriptor` for patch faces} + \cgalParamDefault{`Emptyset_iterator`} + \cgalParamNEnd + \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` @@ -156,19 +162,113 @@ namespace Polygon_mesh_processing { @todo handle the case where an island is reduced to a point */ template - OutputIterator + typename CGAL_NP_TEMPLATE_PARAMETERS> + void // @todo was OutputIterator triangulate_hole(PolygonMesh& pmesh, typename boost::graph_traits::halfedge_descriptor border_halfedge, - OutputIterator out, - const NamedParameters& np = parameters::default_values()) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; using parameters::get_parameter; using parameters::get_parameter_reference; - typedef typename GetGeomTraits::type GeomTraits; + typedef typename GetGeomTraits::type GeomTraits; + + Emptyset_iterator default_face_output_iterator; + typedef typename internal_np::Lookup_named_param_def::reference Face_output_iterator; + + Face_output_iterator out = choose_parameter(get_parameter_reference(np, internal_np::face_output_iterator), default_face_output_iterator); + + bool use_dt3 = +#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 + false; +#else + choose_parameter(get_parameter(np, internal_np::use_delaunay_triangulation), true); +#endif + + CGAL_precondition(face(border_halfedge, pmesh) == boost::graph_traits::null_face()); + bool use_cdt = +#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 + false; +#else + choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), false); +#endif + + typename GeomTraits::FT max_squared_distance = typename GeomTraits::FT(-1); + if (use_cdt) { + + std::vector points; + typedef Halfedge_around_face_circulator Hedge_around_face_circulator; + const auto vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)); + Hedge_around_face_circulator circ(border_halfedge, pmesh), done(circ); + do { + points.push_back(get(vpmap, target(*circ, pmesh))); + } while (++circ != done); + + const typename GeomTraits::Iso_cuboid_3 bbox = CGAL::bounding_box(points.begin(), points.end()); + typename GeomTraits::FT default_squared_distance = CGAL::abs(CGAL::squared_distance(bbox.vertex(0), bbox.vertex(5))); + default_squared_distance /= typename GeomTraits::FT(16); // one quarter of the bbox height + + const typename GeomTraits::FT threshold_distance = choose_parameter( + get_parameter(np, internal_np::threshold_distance), typename GeomTraits::FT(-1)); + max_squared_distance = default_squared_distance; + if (threshold_distance >= typename GeomTraits::FT(0)) + max_squared_distance = threshold_distance * threshold_distance; + CGAL_assertion(max_squared_distance >= typename GeomTraits::FT(0)); + } + + Hole_filling::Default_visitor default_visitor; + + // @todo was return + internal::triangulate_hole_polygon_mesh( + pmesh, + border_halfedge, + out, + choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)), + 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), + choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor), + max_squared_distance).first; + } + +#ifndef CGAL_NO_DEPRECATED_CODE + /*! + \ingroup PMP_hole_filling_grp + + \deprecated This function is deprecated since \cgal 5.6 and the + overload with the named parameter `face_output_iterator` should be + used instead. + + Triangulates a hole in a polygon mesh. + + + @tparam PolygonMesh a model of `MutableFaceGraph` + @tparam OutputIterator a model of `OutputIterator` + holding `boost::graph_traits::%face_descriptor` for patch faces. + @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + */ + template + CGAL_DEPRECATED + OutputIterator + triangulate_hole(PolygonMesh& pmesh, + typename boost::graph_traits::halfedge_descriptor border_halfedge, + OutputIterator out, + const CGAL_NP_CLASS& np = parameters::default_values()) + { + // As soon as the other one returns something + // return triangulate_hole(pmesh, border_halfedge,np.face_output_iterator(out)); + + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::get_parameter_reference; + + typedef typename GetGeomTraits::type GeomTraits; bool use_dt3 = #ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 @@ -221,7 +321,9 @@ namespace Polygon_mesh_processing { choose_parameter(get_parameter(np, internal_np::do_not_use_cubic_algorithm), false), choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor), max_squared_distance).first; + } +#endif // CGAL_NO_DEPRECATED_CODE /*! \ingroup PMP_hole_filling_grp diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index c5ad5f82e96..b6b7c46efb8 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -29,6 +29,9 @@ CGAL_add_named_parameter(metis_options_t, METIS_options, METIS_options) CGAL_add_named_parameter(vertex_partition_id_t, vertex_partition_id, vertex_partition_id_map) CGAL_add_named_parameter(face_partition_id_t, face_partition_id, face_partition_id_map) +CGAL_add_named_parameter(vertex_output_iterator_t, vertex_output_iterator, vertex_output_iterator) +CGAL_add_named_parameter(face_output_iterator_t, face_output_iterator, face_output_iterator) + CGAL_add_named_parameter(vertex_to_vertex_output_iterator_t, vertex_to_vertex_output_iterator, vertex_to_vertex_output_iterator) CGAL_add_named_parameter(halfedge_to_halfedge_output_iterator_t, halfedge_to_halfedge_output_iterator, halfedge_to_halfedge_output_iterator) CGAL_add_named_parameter(face_to_face_output_iterator_t, face_to_face_output_iterator, face_to_face_output_iterator) @@ -327,4 +330,3 @@ CGAL_add_named_parameter_with_compatibility_ref_only(sizing_field_param_t, sizin CGAL_add_named_parameter_with_compatibility(function_param_t, function_param, function) CGAL_add_named_parameter_with_compatibility(bounding_object_param_t, bounding_object_param, bounding_object) - From 8708d348dd05a7a4ba9eb4fe2af3c316bc769a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 29 Nov 2022 13:58:40 +0100 Subject: [PATCH 02/11] remove extra _t --- .../include/CGAL/Polygon_mesh_processing/triangulate_hole.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7b0aa01149f..7e27eeeebdd 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 @@ -82,7 +82,7 @@ namespace Polygon_mesh_processing { \cgalNamedParamsBegin - \cgalParamNBegin{face_output_iterator_t} + \cgalParamNBegin{face_output_iterator} \cgalParamDescription{iterator over patch faces} \cgalParamType{a model of `OutputIterator` holding `boost::graph_traits::%face_descriptor` for patch faces} From c07dc61b4f47863936f4dcf1ba489e499c9ded6d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 29 Nov 2022 13:13:07 +0000 Subject: [PATCH 03/11] Use new version in test --- .../triangulate_hole_Polyhedron_3_no_delaunay_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1dcb214fe39..15aa7558d45 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 @@ -134,7 +134,7 @@ void test_triangulate_hole(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::triangulate_hole(poly, *it, CGAL::parameters::face_output_iterator(back_inserter(patch))); if(patch.empty()) { std::cerr << " Error: empty patch created." << std::endl; assert(false); From 352860ffa4eb2c68b5d96c877db2357c7f219faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 29 Nov 2022 14:24:11 +0100 Subject: [PATCH 04/11] one solution for the return type --- .../triangulate_hole.h | 36 +++++++++---------- ...ate_hole_Polyhedron_3_no_delaunay_test.cpp | 18 ++++++---- 2 files changed, 29 insertions(+), 25 deletions(-) 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 7e27eeeebdd..b951d9eca74 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 @@ -151,7 +151,8 @@ namespace Polygon_mesh_processing { \cgalNamedParamsEnd - @return `out` + @return if an output iterator `out` has been passed to `np` in `face_output_iterator()`, then `out` is returned, + otherwise `Emptyset_iterator()` is returned. \todo handle islands @todo Replace border_halfedge by a range of border halfedges. @@ -163,7 +164,7 @@ namespace Polygon_mesh_processing { */ template - void // @todo was OutputIterator + auto triangulate_hole(PolygonMesh& pmesh, typename boost::graph_traits::halfedge_descriptor border_halfedge, const CGAL_NP_CLASS& np = parameters::default_values()) @@ -174,12 +175,11 @@ namespace Polygon_mesh_processing { typedef typename GetGeomTraits::type GeomTraits; - Emptyset_iterator default_face_output_iterator; typedef typename internal_np::Lookup_named_param_def::reference Face_output_iterator; + Emptyset_iterator>::type Face_output_iterator; - Face_output_iterator out = choose_parameter(get_parameter_reference(np, internal_np::face_output_iterator), default_face_output_iterator); + Face_output_iterator out = choose_parameter(get_parameter(np, internal_np::face_output_iterator)); bool use_dt3 = #ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 @@ -221,18 +221,18 @@ namespace Polygon_mesh_processing { Hole_filling::Default_visitor default_visitor; - // @todo was return - internal::triangulate_hole_polygon_mesh( - pmesh, - border_halfedge, - out, - choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)), - 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), - choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor), - max_squared_distance).first; + return + internal::triangulate_hole_polygon_mesh( + pmesh, + border_halfedge, + out, + choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)), + 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), + choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor), + max_squared_distance).first; } #ifndef CGAL_NO_DEPRECATED_CODE @@ -264,7 +264,7 @@ namespace Polygon_mesh_processing { // As soon as the other one returns something // return triangulate_hole(pmesh, border_halfedge,np.face_output_iterator(out)); - using parameters::choose_parameter; + using parameters::choose_parameter; using parameters::get_parameter; using parameters::get_parameter_reference; 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 15aa7558d45..1a9ffb42f24 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,8 @@ 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::parameters::use_delaunay_triangulation(true)); + poly, *it, CGAL::parameters::use_delaunay_triangulation(true). + face_output_iterator(back_inserter(patch))); if(patch.empty()) { continue; } } @@ -161,15 +162,17 @@ 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::parameters::use_delaunay_triangulation(false)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, + CGAL::parameters::use_delaunay_triangulation(false). + face_output_iterator(back_inserter(patch))); 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::parameters::use_delaunay_triangulation(true)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, + CGAL::parameters::use_delaunay_triangulation(true). + face_output_iterator(back_inserter(patch))); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; assert(false); @@ -258,11 +261,12 @@ void test_ouput_iterators_triangulate_hole(const std::string file_name) { typename std::vector::iterator it_2 = border_reps_2.begin(); for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it, ++it_2) { std::vector patch; - CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, CGAL::parameters::face_output_iterator(back_inserter(patch))); std::vector patch_2 = patch; Facet_handle* output_it = - CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, &*patch_2.begin()); + CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, + CGAL::parameters::face_output_iterator(&*patch_2.begin())); if(patch.size() != (std::size_t)(output_it - &*patch_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; From 63ffb5e82fcd91acc2644023eebe92017b498a24 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 29 Nov 2022 14:49:59 +0000 Subject: [PATCH 05/11] Do the same for the other hole filling functions --- .../triangulate_hole.h | 238 +++++++++++------- ...ate_hole_Polyhedron_3_no_delaunay_test.cpp | 22 +- 2 files changed, 150 insertions(+), 110 deletions(-) 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 b951d9eca74..00f18d5b40c 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 @@ -243,7 +243,7 @@ namespace Polygon_mesh_processing { overload with the named parameter `face_output_iterator` should be used instead. - Triangulates a hole in a polygon mesh. + \briefTriangulates a hole in a polygon mesh. @tparam PolygonMesh a model of `MutableFaceGraph` @@ -261,67 +261,7 @@ namespace Polygon_mesh_processing { OutputIterator out, const CGAL_NP_CLASS& np = parameters::default_values()) { - // As soon as the other one returns something - // return triangulate_hole(pmesh, border_halfedge,np.face_output_iterator(out)); - - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::get_parameter_reference; - - typedef typename GetGeomTraits::type GeomTraits; - - bool use_dt3 = -#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 - false; -#else - choose_parameter(get_parameter(np, internal_np::use_delaunay_triangulation), true); -#endif - - CGAL_precondition(face(border_halfedge, pmesh) == boost::graph_traits::null_face()); - bool use_cdt = -#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 - false; -#else - choose_parameter(get_parameter(np, internal_np::use_2d_constrained_delaunay_triangulation), false); -#endif - - typename GeomTraits::FT max_squared_distance = typename GeomTraits::FT(-1); - if (use_cdt) { - - std::vector points; - typedef Halfedge_around_face_circulator Hedge_around_face_circulator; - const auto vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)); - Hedge_around_face_circulator circ(border_halfedge, pmesh), done(circ); - do { - points.push_back(get(vpmap, target(*circ, pmesh))); - } while (++circ != done); - - const typename GeomTraits::Iso_cuboid_3 bbox = CGAL::bounding_box(points.begin(), points.end()); - typename GeomTraits::FT default_squared_distance = CGAL::abs(CGAL::squared_distance(bbox.vertex(0), bbox.vertex(5))); - default_squared_distance /= typename GeomTraits::FT(16); // one quarter of the bbox height - - const typename GeomTraits::FT threshold_distance = choose_parameter( - get_parameter(np, internal_np::threshold_distance), typename GeomTraits::FT(-1)); - max_squared_distance = default_squared_distance; - if (threshold_distance >= typename GeomTraits::FT(0)) - max_squared_distance = threshold_distance * threshold_distance; - CGAL_assertion(max_squared_distance >= typename GeomTraits::FT(0)); - } - - Hole_filling::Default_visitor default_visitor; - - return internal::triangulate_hole_polygon_mesh( - pmesh, - border_halfedge, - out, - choose_parameter(get_parameter(np, internal_np::vertex_point), get_property_map(vertex_point, pmesh)), - 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), - choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor), - max_squared_distance).first; - + return triangulate_hole(pmesh, border_halfedge,np.face_output_iterator(out)); } #endif // CGAL_NO_DEPRECATED_CODE @@ -330,19 +270,28 @@ namespace Polygon_mesh_processing { @brief triangulates and refines a hole in a polygon mesh. @tparam PolygonMesh must be model of `MutableFaceGraph` - @tparam FacetOutputIterator model of `OutputIterator` - holding `boost::graph_traits::%face_descriptor` for patch faces. - @tparam VertexOutputIterator model of `OutputIterator` - holding `boost::graph_traits::%vertex_descriptor` for patch vertices. @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @param pmesh polygon mesh which has the hole @param border_halfedge a border halfedge incident to the hole - @param face_out output iterator over patch faces - @param vertex_out output iterator over patch vertices without including the boundary @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below \cgalNamedParamsBegin + + \cgalParamNBegin{face_output_iterator} + \cgalParamDescription{iterator over patch faces} + \cgalParamType{a model of `OutputIterator` + holding `boost::graph_traits::%face_descriptor` for patch faces} + \cgalParamDefault{`Emptyset_iterator`} + \cgalParamNEnd + + \cgalParamNBegin{vertex_output_iterator} + \cgalParamDescription{iterator over patch vertices} + \cgalParamType{a model of `OutputIterator` + holding `boost::graph_traits::%vertex_descriptor` for patch vertices} + \cgalParamDefault{`Emptyset_iterator`} + \cgalParamNEnd + \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` @@ -411,7 +360,7 @@ namespace Polygon_mesh_processing { \cgalParamNEnd \cgalNamedParamsEnd - @return pair of `face_out` and `vertex_out` + @return pair of face and vertex output iterator \sa CGAL::Polygon_mesh_processing::triangulate_hole() \sa CGAL::Polygon_mesh_processing::refine() @@ -419,53 +368,108 @@ namespace Polygon_mesh_processing { \todo handle islands */ template - std::pair - triangulate_and_refine_hole(PolygonMesh& pmesh, + typename CGAL_NP_TEMPLATE_PARAMETERS> + auto + triangulate_and_refine_hole(PolygonMesh& pmesh, typename boost::graph_traits::halfedge_descriptor border_halfedge, - FaceOutputIterator face_out, - VertexOutputIterator vertex_out, - const NamedParameters& np = parameters::default_values()) + const CGAL_NP_CLASS& np = parameters::default_values()) { using parameters::choose_parameter; + using parameters::get_parameter; using parameters::get_parameter_reference; + typedef typename internal_np::Lookup_named_param_def::type Face_output_iterator; + + Face_output_iterator face_out = choose_parameter(get_parameter(np, internal_np::face_output_iterator)); + + typedef typename internal_np::Lookup_named_param_def::type Vertex_output_iterator; + + Vertex_output_iterator vertex_out = choose_parameter(get_parameter(np, internal_np::vertex_output_iterator)); + 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); Hole_filling::Default_visitor default_visitor; typedef typename internal_np::Lookup_named_param_def::reference Visitor; Visitor visitor = choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor); visitor.start_refine_phase(); - std::pair res = refine(pmesh, patch, face_out, vertex_out, np); + std::pair res = refine(pmesh, patch, face_out, vertex_out, np); visitor.end_refine_phase(); return res; } + +#ifndef CGAL_NO_DEPRECATED_CODE + /*! + \ingroup PMP_hole_filling_grp + + \deprecated This function is deprecated since \cgal 5.6 and the + overload with the named parameters `face_output_iterator` and + `vertex_output_iterator` should be used instead. + + @brief triangulates and refines a hole in a polygon mesh. + + @tparam PolygonMesh must be model of `MutableFaceGraph` + @tparam FaceOutputIterator model of `OutputIterator` + holding `boost::graph_traits::%face_descriptor` for patch faces. + @tparam VertexOutputIterator model of `OutputIterator` + holding `boost::graph_traits::%vertex_descriptor` for patch vertices. + @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + */ + + template + CGAL_DEPRECATED + std::pair + triangulate_and_refine_hole(PolygonMesh& pmesh, + typename boost::graph_traits::halfedge_descriptor border_halfedge, + FaceOutputIterator face_out, + VertexOutputIterator vertex_out, + const CGAL_NP_CLASS& np = parameters::default_values()) + { + return triangulate_and_refine_hole(pmesh, border_halfedge, + np.face_output_iterator(face_out).vertex_output_iterator(vertex_out)); + } +#endif // CGAL_NO_DEPRECATED_CODE + /*! \ingroup PMP_hole_filling_grp @brief triangulates, refines and fairs a hole in a polygon mesh. @tparam PolygonMesh a model of `MutableFaceGraph` - @tparam FaceOutputIterator model of `OutputIterator` - holding `boost::graph_traits::%face_descriptor` for patch faces - @tparam VertexOutputIterator model of `OutputIterator` - holding `boost::graph_traits::%vertex_descriptor` for patch vertices @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @param pmesh polygon mesh which has the hole @param border_halfedge a border halfedge incident to the hole - @param face_out output iterator over patch faces - @param vertex_out output iterator over patch vertices without including the boundary + @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below \cgalNamedParamsBegin + + \cgalParamNBegin{face_output_iterator} + \cgalParamDescription{iterator over patch faces} + \cgalParamType{a model of `OutputIterator` + holding `boost::graph_traits::%face_descriptor` for patch faces} + \cgalParamDefault{`Emptyset_iterator`} + \cgalParamNEnd + + \cgalParamNBegin{vertex_output_iterator} + \cgalParamDescription{iterator over patch vertices} + \cgalParamType{a model of `OutputIterator` + holding `boost::graph_traits::%vertex_descriptor` for patch vertices} + \cgalParamDefault{`Emptyset_iterator`} + \cgalParamNEnd + \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` @@ -543,10 +547,8 @@ namespace Polygon_mesh_processing { \cgalParamNEnd \cgalNamedParamsEnd - @return tuple of - - `bool`: `true` if fairing is successful - - `face_out` - - `vertex_out` + @return tuple of `bool` with `true` if fairing is successful, and + the face and vertex output iterator \sa CGAL::Polygon_mesh_processing::triangulate_hole() \sa CGAL::Polygon_mesh_processing::refine() @@ -555,23 +557,32 @@ namespace Polygon_mesh_processing { \todo handle islands */ template - std::tuple + typename CGAL_NP_TEMPLATE_PARAMETERS> + auto triangulate_refine_and_fair_hole(PolygonMesh& pmesh, typename boost::graph_traits::halfedge_descriptor border_halfedge, - FaceOutputIterator face_out, - VertexOutputIterator vertex_out, - const NamedParameters& np = parameters::default_values()) + const CGAL_NP_CLASS& np = parameters::default_values()) { CGAL_precondition(CGAL::is_triangle_mesh(pmesh)); using parameters::choose_parameter; + using parameters::get_parameter; using parameters::get_parameter_reference; CGAL_precondition(is_valid_halfedge_descriptor(border_halfedge, pmesh)); + typedef typename internal_np::Lookup_named_param_def::type Face_output_iterator; + + Face_output_iterator face_out = choose_parameter(get_parameter(np, internal_np::face_output_iterator)); + + typedef typename internal_np::Lookup_named_param_def::type Vertex_output_iterator; + + Vertex_output_iterator vertex_out = choose_parameter(get_parameter(np, internal_np::vertex_output_iterator)); + std::vector::vertex_descriptor> patch; face_out = triangulate_and_refine_hole (pmesh, border_halfedge, face_out, std::back_inserter(patch), np).first; @@ -580,7 +591,7 @@ namespace Polygon_mesh_processing { Hole_filling::Default_visitor default_visitor; typedef typename internal_np::Lookup_named_param_def::reference Visitor; Visitor visitor = choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor); @@ -592,6 +603,39 @@ namespace Polygon_mesh_processing { return std::make_tuple(fair_success, face_out, vertex_out); } + #ifndef CGAL_NO_DEPRECATED_CODE + /*! + \ingroup PMP_hole_filling_grp + + \deprecated This function is deprecated since \cgal 5.6 and the + overload with the named parameters `face_output_iterator` and + `vertex_output_iterator` should be used instead. + + \brief Triangulates, refines, and fairs a hole in a polygon mesh. + + @tparam PolygonMesh a model of `MutableFaceGraph` + @tparam FaceOutputIterator model of `OutputIterator` + holding `boost::graph_traits::%face_descriptor` for patch faces. + @tparam VertexOutputIterator model of `OutputIterator` + holding `boost::graph_traits::%vertex_descriptor` for patch vertices. + @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + */ + template + CGAL_DEPRECATED + std::tuple + triangulate_refine_and_fair_hole(PolygonMesh& pmesh, + typename boost::graph_traits::halfedge_descriptor border_halfedge, + FaceOutputIterator face_out, + VertexOutputIterator vertex_out, + const CGAL_NP_CLASS& np = parameters::default_values()) + { + return triangulate_refine_and_fair_hole(pmesh, border_halfedge, np.face_output_iterator(face_out).vertex_output_iterator(vertex_out)); + } +#endif // CGAL_NO_DEPRECATED_CODE + /*! \ingroup PMP_hole_filling_grp creates triangles to fill the hole defined by points in the range `points`. 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 1a9ffb42f24..af6459bc13f 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,8 +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, CGAL::parameters::use_delaunay_triangulation(true). - face_output_iterator(back_inserter(patch))); + poly, *it, back_inserter(patch),CGAL::parameters::use_delaunay_triangulation(true)); if(patch.empty()) { continue; } } @@ -162,17 +161,15 @@ 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, - CGAL::parameters::use_delaunay_triangulation(false). - face_output_iterator(back_inserter(patch))); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), + 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, - CGAL::parameters::use_delaunay_triangulation(true). - face_output_iterator(back_inserter(patch))); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), + CGAL::parameters::use_delaunay_triangulation(true)); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; assert(false); @@ -197,7 +194,7 @@ void test_triangulate_and_refine_hole(const std::string file_name) { std::vector patch_facets; std::vector patch_vertices; CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, *it, - back_inserter(patch_facets), back_inserter(patch_vertices)); + CGAL::parameters::face_output_iterator(back_inserter(patch_facets)).vertex_output_iterator(back_inserter(patch_vertices))); if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; @@ -228,7 +225,7 @@ void test_triangulate_refine_and_fair_hole(const std::string file_name) { std::vector patch_facets; std::vector patch_vertices; CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, - *it, back_inserter(patch_facets), back_inserter(patch_vertices)); + *it, CGAL::parameters::face_output_iterator(back_inserter(patch_facets)).vertex_output_iterator(back_inserter(patch_vertices))); if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; @@ -261,12 +258,11 @@ void test_ouput_iterators_triangulate_hole(const std::string file_name) { typename std::vector::iterator it_2 = border_reps_2.begin(); for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it, ++it_2) { std::vector patch; - CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, CGAL::parameters::face_output_iterator(back_inserter(patch))); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch)); std::vector patch_2 = patch; Facet_handle* output_it = - CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, - CGAL::parameters::face_output_iterator(&*patch_2.begin())); + CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, &*patch_2.begin()); if(patch.size() != (std::size_t)(output_it - &*patch_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; From a2e599b23dbff2f77338ddd38c5c13de8f7dbb3a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 29 Nov 2022 16:55:43 +0000 Subject: [PATCH 06/11] Fix typos --- .../include/CGAL/Polygon_mesh_processing/triangulate_hole.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 00f18d5b40c..19ad06bca15 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 @@ -151,8 +151,7 @@ namespace Polygon_mesh_processing { \cgalNamedParamsEnd - @return if an output iterator `out` has been passed to `np` in `face_output_iterator()`, then `out` is returned, - otherwise `Emptyset_iterator()` is returned. + @return the face output iterator \todo handle islands @todo Replace border_halfedge by a range of border halfedges. @@ -243,7 +242,7 @@ namespace Polygon_mesh_processing { overload with the named parameter `face_output_iterator` should be used instead. - \briefTriangulates a hole in a polygon mesh. + \brief Triangulates a hole in a polygon mesh. @tparam PolygonMesh a model of `MutableFaceGraph` From 2b26b8dd319b04256f08e23a035c96c66b32fdf8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 30 Nov 2022 07:58:02 +0000 Subject: [PATCH 07/11] Don't use deprecated code in examples --- .../Polygon_mesh_processing/hole_filling_example.cpp | 6 +++--- .../Polygon_mesh_processing/hole_filling_example_LCC.cpp | 6 +++--- .../Polygon_mesh_processing/hole_filling_example_OM.cpp | 6 +++--- .../Polygon_mesh_processing/hole_filling_example_SM.cpp | 4 ++-- .../hole_filling_visitor_example.cpp | 6 ------ .../include/CGAL/Polygon_mesh_processing/triangulate_hole.h | 4 ++-- 6 files changed, 13 insertions(+), 19 deletions(-) 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 41d23352506..8c7d009461b 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,9 +41,9 @@ int main(int argc, char* argv[]) std::vector patch_vertices; bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(poly, h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices), - CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, poly)) + CGAL::parameters::face_output_iterator(std::back_inserter(patch_facets)) + .vertex_output_iterator(std::back_inserter(patch_vertices)) + .vertex_point_map(get(CGAL::vertex_point, poly)) .geom_traits(Kernel()))); std::cout << " Number of facets in constructed patch: " << patch_facets.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 2c5550009d2..be7b6166e4e 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,9 +43,9 @@ int main(int argc, char* argv[]) std::vector patch_vertices; bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices), - CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) + CGAL::parameters::face_output_iterator(std::back_inserter(patch_facets)) + .vertex_output_iterator(std::back_inserter(patch_vertices)) + .vertex_point_map(get(CGAL::vertex_point, mesh)) .geom_traits(Kernel()))); std::cout << "* Number of facets in constructed patch: " << patch_facets.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 db5082b82b4..46371fd8df1 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 @@ -40,9 +40,9 @@ int main(int argc, char* argv[]) std::vector patch_facets; std::vector patch_vertices; bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices), - CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) + CGAL::parameters::face_output_iterator(std::back_inserter(patch_facets)) + .vertex_output_iterator(std::back_inserter(patch_vertices)) + .vertex_point_map(get(CGAL::vertex_point, mesh)) .geom_traits(Kernel()))); assert(CGAL::is_valid_polygon_mesh(mesh)); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp index b20e4e568b8..b7e9177269b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp @@ -79,8 +79,8 @@ int main(int argc, char* argv[]) std::vector patch_vertices; bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices))); + CGAL::parameters::face_output_iterator(std::back_inserter(patch_facets)) + .vertex_output_iterator(std::back_inserter(patch_vertices)))); 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_visitor_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_visitor_example.cpp index 3586d28edf0..62db322764a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_visitor_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_visitor_example.cpp @@ -160,23 +160,17 @@ int main(int argc, char* argv[]) !is_small_hole(h, mesh, max_hole_diam, max_num_hole_edges)) continue; - std::vector patch_facets; - std::vector patch_vertices; Progress progress(10.0); bool success = false; try { success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices), CGAL::parameters::visitor(std::ref(progress)).use_delaunay_triangulation(true))); } catch (const Stop&) { std::cout << "We stopped with a timeout" << std::endl; } - 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; std::cout << " Is fairing successful: " << success << std::endl; ++nb_holes; } 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 19ad06bca15..e04ebf64113 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 @@ -242,7 +242,7 @@ namespace Polygon_mesh_processing { overload with the named parameter `face_output_iterator` should be used instead. - \brief Triangulates a hole in a polygon mesh. + \brief triangulates a hole in a polygon mesh. @tparam PolygonMesh a model of `MutableFaceGraph` @@ -610,7 +610,7 @@ namespace Polygon_mesh_processing { overload with the named parameters `face_output_iterator` and `vertex_output_iterator` should be used instead. - \brief Triangulates, refines, and fairs a hole in a polygon mesh. + \brief triangulates, refines, and fairs a hole in a polygon mesh. @tparam PolygonMesh a model of `MutableFaceGraph` @tparam FaceOutputIterator model of `OutputIterator` From 2a2e319061fee867e76ee10ca6f676a08120db62 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 30 Nov 2022 08:16:57 +0000 Subject: [PATCH 08/11] Don't use deprecated code in demo --- .../Plugins/PMP/Hole_filling_plugin.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp index 94300e439fa..fbc5fe8af1b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp @@ -706,9 +706,10 @@ bool Polyhedron_demo_hole_filling_plugin::fill 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::parameters::density_control_factor(alpha). + CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, it, + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch)). + density_control_factor(alpha). use_delaunay_triangulation(use_DT)); } else { @@ -716,9 +717,9 @@ bool Polyhedron_demo_hole_filling_plugin::fill bool success; 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(), + success = std::get<0>(CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, it, CGAL::parameters:: + face_output_iterator(std::back_inserter(patch)). weight_calculator(CGAL::Weights::Uniform_weight()). density_control_factor(alpha). fairing_continuity(continuity). @@ -726,9 +727,9 @@ bool Polyhedron_demo_hole_filling_plugin::fill } else { 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(), + success = std::get<0>(CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, it, CGAL::parameters:: + face_output_iterator(std::back_inserter(patch)). weight_calculator(CGAL::Weights::Secure_cotangent_weight_with_voronoi_area(poly, pmap)). density_control_factor(alpha). fairing_continuity(continuity). From 1adb13edc8246084aa6b7d3fcc712172f1b5a60f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 6 Dec 2022 12:34:26 +0000 Subject: [PATCH 09/11] Do not use deprecated functions --- .../Classification/gis_tutorial_example.cpp | 3 +- .../triangulate_hole.h | 4 +- ...ate_hole_Polyhedron_3_no_delaunay_test.cpp | 33 ++++---- .../triangulate_hole_Polyhedron_3_test.cpp | 76 ++++++++++++------- .../triangulate_hole_with_cdt_2_test.cpp | 6 +- .../Plugins/PMP/Hole_filling_plugin.cpp | 7 +- 6 files changed, 78 insertions(+), 51 deletions(-) diff --git a/Classification/examples/Classification/gis_tutorial_example.cpp b/Classification/examples/Classification/gis_tutorial_example.cpp index e02d128a307..ba3c15d3825 100644 --- a/Classification/examples/Classification/gis_tutorial_example.cpp +++ b/Classification/examples/Classification/gis_tutorial_example.cpp @@ -473,8 +473,7 @@ int main (int argc, char** argv) // Fill all holes except the bigest (which is the outer hull of the mesh) for (Mesh::Halfedge_index hi : holes) if (hi != outer_hull) - CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole - (dtm_mesh, hi, CGAL::Emptyset_iterator(), CGAL::Emptyset_iterator()); + CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole (dtm_mesh, hi); // Save DTM with holes filled std::ofstream dtm_filled_ofile ("dtm_filled.ply", std::ios_base::binary); 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 e04ebf64113..f574822c926 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 @@ -390,7 +390,7 @@ namespace Polygon_mesh_processing { Vertex_output_iterator vertex_out = choose_parameter(get_parameter(np, internal_np::vertex_output_iterator)); std::vector::face_descriptor> patch; - triangulate_hole(pmesh, border_halfedge, std::back_inserter(patch), np); + triangulate_hole(pmesh, border_halfedge, np.face_output_iterator(std::back_inserter(patch))); face_out = std::copy(patch.begin(), patch.end(), face_out); Hole_filling::Default_visitor default_visitor; @@ -584,7 +584,7 @@ namespace Polygon_mesh_processing { std::vector::vertex_descriptor> patch; face_out = triangulate_and_refine_hole - (pmesh, border_halfedge, face_out, std::back_inserter(patch), np).first; + (pmesh, border_halfedge, np.face_output_iterator(face_out).vertex_output_iterator(std::back_inserter(patch))).first; CGAL_postcondition(CGAL::is_triangle_mesh(pmesh)); 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 af6459bc13f..a11648436a5 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::parameters::use_delaunay_triangulation(true)); + poly, *it, CGAL::parameters::use_delaunay_triangulation(true).face_output_iterator(back_inserter(patch))); if(patch.empty()) { continue; } } @@ -161,15 +161,15 @@ 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::parameters::use_delaunay_triangulation(false)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, + CGAL::parameters::use_delaunay_triangulation(false).face_output_iterator(back_inserter(patch))); 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::parameters::use_delaunay_triangulation(true)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, + CGAL::parameters::use_delaunay_triangulation(true).face_output_iterator(back_inserter(patch))); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; assert(false); @@ -258,11 +258,11 @@ void test_ouput_iterators_triangulate_hole(const std::string file_name) { typename std::vector::iterator it_2 = border_reps_2.begin(); for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it, ++it_2) { std::vector patch; - CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, CGAL::parameters::face_output_iterator(back_inserter(patch))); std::vector patch_2 = patch; Facet_handle* output_it = - CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, &*patch_2.begin()); + CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, CGAL::parameters::face_output_iterator(& *patch_2.begin())); if(patch.size() != (std::size_t)(output_it - &*patch_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; @@ -291,8 +291,8 @@ void test_ouput_iterators_triangulate_and_refine_hole(const std::string file_nam for(typename std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it, ++it_2) { std::vector patch_facets; std::vector patch_vertices; - CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, - *it, back_inserter(patch_facets), back_inserter(patch_vertices)); + CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, *it, + CGAL::parameters::face_output_iterator(back_inserter(patch_facets)).vertex_output_iterator(back_inserter(patch_vertices))); // create enough space to hold outputs std::vector patch_facets_2 = patch_facets; std::vector patch_vertices_2 = patch_vertices; @@ -300,7 +300,7 @@ void test_ouput_iterators_triangulate_and_refine_hole(const std::string file_nam std::pair output_its = CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly_2, - *it_2, &*patch_facets_2.begin(), &*patch_vertices_2.begin()); + *it_2, CGAL::parameters::face_output_iterator(& *patch_facets_2.begin()).vertex_output_iterator(& *patch_vertices_2.begin())); if(patch_facets.size() != (std::size_t) (output_its.first - &*patch_facets_2.begin())) { std::cout << " Error: returned facet output iterator is not valid!" << std::endl; @@ -337,22 +337,29 @@ void test_triangulate_refine_and_fair_hole_compile() { // use all param 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), + (poly, border_reps[0], CGAL::parameters:: + face_output_iterator(back_inserter(patch_facets)). + vertex_output_iterator(back_inserter(patch_vertices)). weight_calculator(CGAL::Weights::Uniform_weight()). sparse_linear_solver(Default_solver())); // default solver 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), + (poly, border_reps[0], CGAL::parameters:: + face_output_iterator(back_inserter(patch_facets)). + vertex_output_iterator(back_inserter(patch_vertices)). weight_calculator(CGAL::Weights::Uniform_weight())); // default solver and weight 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)); + (poly, border_reps[0], + CGAL::parameters:: + face_output_iterator(back_inserter(patch_facets)). + vertex_output_iterator(back_inserter(patch_vertices))); } template 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 9933d3ab217..146eed2fd87 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 @@ -138,8 +138,10 @@ void test_triangulate_hole(const std::string file_name, bool use_cdt) { 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::parameters::use_2d_constrained_delaunay_triangulation(use_cdt)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch)). + use_2d_constrained_delaunay_triangulation(use_cdt)); if(patch.empty()) { std::cerr << " Error: empty patch created." << std::endl; assert(false); @@ -163,16 +165,17 @@ 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::triangulate_hole(poly, *it, CGAL::parameters::use_delaunay_triangulation(false) + .face_output_iterator(back_inserter(patch)) .use_2d_constrained_delaunay_triangulation(use_cdt)); 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::parameters::use_delaunay_triangulation(true)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, + CGAL::parameters::use_delaunay_triangulation(true).face_output_iterator(back_inserter(patch))); if(!patch.empty()) { std::cerr << " Error: patch should be empty" << std::endl; assert(false); @@ -193,8 +196,10 @@ void test_triangulate_and_refine_hole(const std::string file_name, bool use_cdt) std::vector patch_facets; std::vector patch_vertices; CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, *it, - back_inserter(patch_facets), back_inserter(patch_vertices), - CGAL::parameters::use_2d_constrained_delaunay_triangulation(use_cdt)); + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch_facets)). + vertex_output_iterator(std::back_inserter(patch_vertices)). + use_2d_constrained_delaunay_triangulation(use_cdt)); if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; @@ -220,9 +225,11 @@ void test_triangulate_refine_and_fair_hole(const std::string file_name, bool use for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it) { std::vector patch_facets; std::vector patch_vertices; - CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, - *it, back_inserter(patch_facets), back_inserter(patch_vertices), - CGAL::parameters::use_2d_constrained_delaunay_triangulation(use_cdt)); + CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, *it, + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch_facets)). + vertex_output_iterator(std::back_inserter(patch_vertices)). + use_2d_constrained_delaunay_triangulation(use_cdt)); if(patch_facets.empty()) { std::cerr << " Error: empty patch created." << std::endl; @@ -251,12 +258,14 @@ void test_ouput_iterators_triangulate_hole(const std::string file_name, bool use std::vector::iterator it_2 = border_reps_2.begin(); for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it, ++it_2) { std::vector patch; - CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, back_inserter(patch), - CGAL::parameters::use_2d_constrained_delaunay_triangulation(use_cdt)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, *it, + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch)). + use_2d_constrained_delaunay_triangulation(use_cdt)); std::vector patch_2 = patch; Facet_handle* output_it = - CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, &*patch_2.begin()); + CGAL::Polygon_mesh_processing::triangulate_hole(poly_2, *it_2, CGAL::parameters::face_output_iterator(& *patch_2.begin())); if(patch.size() != (std::size_t)(output_it - &*patch_2.begin())) { std::cerr << " Error: returned facet output iterator is not valid!" << std::endl; @@ -282,18 +291,22 @@ void test_ouput_iterators_triangulate_and_refine_hole(const std::string file_nam for(std::vector::iterator it = border_reps.begin(); it != border_reps.end(); ++it, ++it_2) { std::vector patch_facets; std::vector patch_vertices; - CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, - *it, back_inserter(patch_facets), back_inserter(patch_vertices), - CGAL::parameters::use_2d_constrained_delaunay_triangulation(use_cdt)); + CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, *it, + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch_facets)). + vertex_output_iterator(std::back_inserter(patch_vertices)). + use_2d_constrained_delaunay_triangulation(use_cdt)); // create enough space to hold outputs std::vector patch_facets_2 = patch_facets; std::vector patch_vertices_2 = patch_vertices; if(patch_vertices_2.empty()) { patch_vertices_2.push_back(Vertex_handle()); } //just allocate space for dereferencing std::pair output_its = - CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly_2, - *it_2, &*patch_facets_2.begin(), &*patch_vertices_2.begin(), - CGAL::parameters::use_2d_constrained_delaunay_triangulation(use_cdt)); + CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly_2, *it_2, + CGAL::parameters:: + face_output_iterator(&*patch_facets_2.begin()). + vertex_output_iterator(&*patch_vertices_2.begin()). + use_2d_constrained_delaunay_triangulation(use_cdt)); if(patch_facets.size() != (std::size_t) (output_its.first - &*patch_facets_2.begin())) { std::cout << " Error: returned facet output iterator is not valid!" << std::endl; @@ -327,23 +340,30 @@ void test_triangulate_refine_and_fair_hole_compile() { // use all param 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::parameters:: - weight_calculator(CGAL::Weights::Uniform_weight()). - sparse_linear_solver(Default_solver()). - use_2d_constrained_delaunay_triangulation(false)); + (poly, border_reps[0], + CGAL::parameters:: + face_output_iterator(back_inserter(patch_facets)). + vertex_output_iterator(back_inserter(patch_vertices)). + weight_calculator(CGAL::Weights::Uniform_weight()). + sparse_linear_solver(Default_solver()). + use_2d_constrained_delaunay_triangulation(false)); // default solver 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::parameters:: - weight_calculator(CGAL::Weights::Uniform_weight())); + (poly, border_reps[0], + CGAL::parameters:: + face_output_iterator(back_inserter(patch_facets)). + vertex_output_iterator(back_inserter(patch_vertices)). + weight_calculator(CGAL::Weights::Uniform_weight())); // default solver and weight 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)); + (poly, border_reps[0], + CGAL::parameters:: + face_output_iterator(back_inserter(patch_facets)). + vertex_output_iterator(back_inserter(patch_vertices))); } void generate_elephant_with_hole() 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 8ab2e2afd71..8f1ede58b93 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 @@ -86,9 +86,9 @@ void test_triangulate_hole_with_cdt_2( CGAL::Polygon_mesh_processing::triangulate_hole( pmesh, h, - std::back_inserter(patch_faces), - CGAL::parameters::vertex_point_map( - get(CGAL::vertex_point, pmesh)). + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch_faces)). + vertex_point_map(get(CGAL::vertex_point, pmesh)). use_2d_constrained_delaunay_triangulation(true). geom_traits(GeomTraits())); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp index fbc5fe8af1b..da3c06dbf72 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp @@ -701,9 +701,10 @@ bool Polyhedron_demo_hole_filling_plugin::fill CGAL::Timer timer; timer.start(); std::vector patch; if(action_index == 0) { - CGAL::Polygon_mesh_processing::triangulate_hole(poly, - it, std::back_inserter(patch), - CGAL::parameters::use_delaunay_triangulation(use_DT)); + CGAL::Polygon_mesh_processing::triangulate_hole(poly, it, + CGAL::parameters:: + face_output_iterator(std::back_inserter(patch)). + use_delaunay_triangulation(use_DT)); } else if(action_index == 1) { CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(poly, it, From 0ac2d8ec0fae68b6d9af8e8ebbda3a3c434544ba Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 9 Dec 2022 07:37:03 +0000 Subject: [PATCH 10/11] Remove the parameters which have become nps --- .../Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp index 1716ea56a09..06640c85b9c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Hole_filling_plugin.cpp @@ -730,13 +730,12 @@ bool Polyhedron_demo_hole_filling_plugin::fill auto vpm = get_property_map(CGAL::vertex_point, poly); auto weight_calc = CGAL::Weights::Secure_cotangent_weight_with_voronoi_area(poly, vpm, EPICK()); - success = std::get<0>(CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly, - it, std::back_inserter(patch), CGAL::Emptyset_iterator(), - CGAL::parameters::face_output_iterator(std::back_inserter(patch)). - weight_calculator(weight_calc). - density_control_factor(alpha). - fairing_continuity(continuity). - use_delaunay_triangulation(use_DT))); + success = std::get<0>(CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole(poly,it, + CGAL::parameters::face_output_iterator(std::back_inserter(patch)). + weight_calculator(weight_calc). + density_control_factor(alpha). + fairing_continuity(continuity). + use_delaunay_triangulation(use_DT))); } if(!success) { print_message("Error: fairing is not successful, only triangulation and refinement are applied!"); } From 4e16d96b59527236b7de12d0185e5981360ea227 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 15 Dec 2022 12:04:32 +0000 Subject: [PATCH 11/11] Update CHANGES.md --- Installation/CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 30e31329e62..837406be878 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -16,6 +16,10 @@ Release date: June 2023 ### [Polygon Mesh Processing](https://doc.cgal.org/5.6/Manual/packages.html#PkgPolygonMeshProcessing) +- **Breaking change**: Deprecated the overloads of functions `CGAL::Polygon_mesh_processing::triangulate_hole()`, + `CGAL::Polygon_mesh_processing::triangulate_and_refine_hole()`, and `CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole()` + which have output iterators for vertices and faces as parameter. They are replaced by overloads with two additional named parameters. + - Added the function `CGAL::Polygon_mesh_processing::surface_Delaunay_remeshing()`, that remeshes a surface triangle mesh following the CGAL tetrahedral Delaunay refinement algorithm.