diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index a8d45d8b867..13cad81b410 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -76,20 +76,6 @@ struct Principal_curvatures_and_directions { namespace internal { -template -typename GT::FT average_edge_length(const PolygonMesh& pmesh) { - const std::size_t n = edges(pmesh).size(); - if (n == 0) - return 0; - - typename GT::FT avg_edge_length = 0; - for (auto e : edges(pmesh)) - avg_edge_length += edge_length(e, pmesh); - - avg_edge_length /= static_cast(n); - return avg_edge_length; -} - template struct Vertex_measures { typename GT::FT area_measure = 0; @@ -650,7 +636,7 @@ void interpolated_corrected_curvatures_one_vertex( typename GT::FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); // calculate avg_edge_length as it is used in case radius is 0, and in the principal curvature computation later - typename GT::FT avg_edge_length = average_edge_length(pmesh); + typename GT::FT avg_edge_length = average_edge_length(pmesh); // if the radius is 0, we use a small epsilon to expand the ball (scaled with the average edge length) if (is_zero(radius)) @@ -799,7 +785,7 @@ private: // if no radius is given, we pass -1 which will make the expansion be only on the incident faces instead of a ball const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - avg_edge_length = average_edge_length(pmesh); + avg_edge_length = average_edge_length(pmesh); set_ball_radius(radius); // check which curvature maps are provided by the user (determines which curvatures are computed) 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 8f1c60347ee..520ebbec9be 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h @@ -217,6 +217,25 @@ squared_edge_length(typename boost::graph_traits::edge_descriptor e return squared_edge_length(halfedge(e, pmesh), pmesh, np); } +template +typename GetGeomTraits::type::FT +average_edge_length(const PolygonMesh& pmesh, + const NamedParameters& np = parameters::default_values()) +{ + typedef typename GetGeomTraits::type GT; + + const std::size_t n = edges(pmesh).size(); + CGAL_assertion(n > 0); + + typename GT::FT avg_edge_length = 0; + for (auto e : edges(pmesh)) + avg_edge_length += edge_length(e, pmesh, np); + + avg_edge_length /= static_cast(n); + return avg_edge_length; +} + /** * \ingroup PMP_measure_grp *