Skip to content

Commit

Permalink
Removed std::vector from the algorithm, now outputting the approximat…
Browse files Browse the repository at this point in the history
…ion points directly to the output iterator.
  • Loading branch information
denizdiktas committed Jun 1, 2023
1 parent fc9c993 commit 34b9a7d
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <CGAL/Arr_tags.h>
#include <CGAL/Arr_enums.h>
#include <CGAL/use.h>
#include <vector>

namespace CGAL {

Expand Down Expand Up @@ -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;
Expand All @@ -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<Approximate_vector_3> 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;
}
Expand All @@ -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<typename LocationType>
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);
}
Expand Down

0 comments on commit 34b9a7d

Please sign in to comment.