From 63ffb5e82fcd91acc2644023eebe92017b498a24 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 29 Nov 2022 14:49:59 +0000 Subject: [PATCH] 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;