From 88f7806d69115c1626c4abfb821b598a3078e18d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 28 Jun 2020 09:52:39 +0200 Subject: Use boost::size for unknown incoming ranges --- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Alpha_complex/include/gudhi') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index c29905f4..231b1ea9 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -299,14 +300,14 @@ Weighted_alpha_complex_3d::Weighted_point_3 wp0(Weighted_alpha_complex_3d::Bare_ Alpha_complex_3d(const InputPointRange& points, WeightRange weights) { static_assert(Weighted, "This constructor is not available for non-weighted versions of Alpha_complex_3d"); static_assert(!Periodic, "This constructor is not available for periodic versions of Alpha_complex_3d"); - GUDHI_CHECK((weights.size() == points.size()), + GUDHI_CHECK(boost::size(weights) == boost::size(points), std::invalid_argument("Points number in range different from weights range number")); std::vector weighted_points_3; std::size_t index = 0; - weighted_points_3.reserve(points.size()); - while ((index < weights.size()) && (index < points.size())) { + weighted_points_3.reserve(boost::size(points)); + while ((index < boost::size(weights)) && (index < boost::size(points))) { weighted_points_3.push_back(Weighted_point_3(points[index], weights[index])); index++; } @@ -388,7 +389,7 @@ Weighted_alpha_complex_3d::Weighted_point_3 wp0(Weighted_alpha_complex_3d::Bare_ FT z_min, FT x_max, FT y_max, FT z_max) { static_assert(Weighted, "This constructor is not available for non-weighted versions of Alpha_complex_3d"); static_assert(Periodic, "This constructor is not available for non-periodic versions of Alpha_complex_3d"); - GUDHI_CHECK((weights.size() == points.size()), + GUDHI_CHECK(boost::size(weights) == boost::size(points), std::invalid_argument("Points number in range different from weights range number")); // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it. GUDHI_CHECK( @@ -398,14 +399,14 @@ Weighted_alpha_complex_3d::Weighted_point_3 wp0(Weighted_alpha_complex_3d::Bare_ std::vector weighted_points_3; std::size_t index = 0; - weighted_points_3.reserve(points.size()); + weighted_points_3.reserve(boost::size(points)); #ifdef GUDHI_DEBUG // Defined in GUDHI_DEBUG to avoid unused variable warning for GUDHI_CHECK FT maximal_possible_weight = 0.015625 * (x_max - x_min) * (x_max - x_min); #endif - while ((index < weights.size()) && (index < points.size())) { + while ((index < boost::size(weights)) && (index < boost::size(points))) { GUDHI_CHECK((weights[index] < maximal_possible_weight) && (weights[index] >= 0), std::invalid_argument("Invalid weight at index " + std::to_string(index + 1) + ". Must be positive and less than maximal possible weight = 1/64*cuboid length " -- cgit v1.2.3