From 34b9a7d356080631fe3a51e81044ea485ec8f002 Mon Sep 17 00:00:00 2001 From: denizdiktas Date: Thu, 1 Jun 2023 13:09:41 +0300 Subject: [PATCH] Removed std::vector from the algorithm, now outputting the approximation points directly to the output iterator. --- .../Arr_geodesic_arc_on_sphere_traits_2.h | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) 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 9812c43c0f3..a23146beb6a 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 @@ -36,7 +36,6 @@ #include #include #include -#include namespace CGAL { @@ -2978,7 +2977,7 @@ class Arr_geodesic_arc_on_sphere_traits_2 : public Kernel_ { auto axisY = CGAL::cross_product(axisZ, axisX); normalize(axisY); - // In this coordinate system the source has local coords (0,0), hence its + // In this coordinate system the source has local coords (0,0), hence its // initial angle with the X-axis is 0 degrees (radians) // Compute the local coordinates and the angle it makes with the X-axis Approximate_number_type theta; @@ -3001,23 +3000,16 @@ class Arr_geodesic_arc_on_sphere_traits_2 : public Kernel_ { int N = std::ceil(theta / dtheta); dtheta = theta / N; - // generate the points - std::vector pts; - pts.reserve(N + 1); - pts.push_back(vs); + // generate the points approximating the curve + const auto loc = Approximate_point_2::NO_BOUNDARY_LOC; + *oi++ = get_approximate_point_2(vs, loc); // source vector for (int i = 1; i < N; ++i) { const Approximate_number_type angle = i * dtheta; auto p = std::cos(angle) * axisX + std::sin(angle) * axisY; - pts.push_back(p); - } - pts.push_back(vt); - - const auto loc = Approximate_point_2::NO_BOUNDARY_LOC; - for (const auto& p : pts) - { - *oi++ = get_approximate_point_2(p, loc); + *oi++ = get_approximate_point_2(p, loc); } + *oi++ = get_approximate_point_2(vt, loc); // target vector return oi; } @@ -3033,9 +3025,8 @@ class Arr_geodesic_arc_on_sphere_traits_2 : public Kernel_ { CGAL::to_double(d.dy()), CGAL::to_double(d.dz())); }; - template Approximate_point_2 get_approximate_point_2(const Approximate_vector_3& v, - const LocationType loc) const { + const Approximate_point_2::Location_type loc) const { Approximate_direction_3 d(v.x(), v.y(), v.z()); return Approximate_point_2(d, loc); }