diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt index 26f23e6c53a..d3536801663 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/CMakeLists.txt @@ -17,4 +17,5 @@ endforeach() if(CGAL_Qt5_FOUND) target_link_libraries(draw_arr PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(conics PUBLIC CGAL::CGAL_Basic_viewer) endif() diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp index a8688f55a98..6720bb7a8d2 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/conics.cpp @@ -2,6 +2,7 @@ // Constructing an arrangement of various conic arcs. #include +#include #ifdef CGAL_USE_CORE @@ -11,6 +12,7 @@ int main() { Arrangement arr; +#if 0 // Insert a hyperbolic arc (C1), supported by the hyperbola y = 1/x // (or: xy - 1 = 0) with the endpoints (1/4, 4) and (2, 1/2). // The arc is counterclockwise oriented. @@ -20,21 +22,24 @@ int main() { // Insert a full ellipse (C2), which is (x/4)^2 + (y/2)^2 = 0 rotated by // phi = 36.87 degrees (such that sin(phi) = 0.6, cos(phi) = 0.8), // yielding: 58x^2 + 72y^2 - 48xy - 360 = 0. - insert(arr, Conic_arc (58, 72, -48, 0, 0, -360)); + insert(arr, Conic_arc(58, 72, -48, 0, 0, -360)); +#endif // Insert the segment (C3) (1, 1) -- (0, -3). insert(arr, Conic_arc(Rat_segment(Rat_point(1, 1), Rat_point(0, -3)))); +#if 0 // Insert a circular arc (C4) supported by the circle x^2 + y^2 = 5^2, // with (-3, 4) and (4, 3) as its endpoints. We want the arc to be // clockwise-oriented, so it passes through (0, 5) as well. Conic_arc c4(Rat_point(-3, 4), Rat_point(0, 5), Rat_point(4, 3)); - insert(arr, c4); +#endif // Insert a full unit circle (C5) that is centered at (0, 4). insert(arr, Conic_arc(Rat_circle(Rat_point(0,4), 1))); +#if 0 // Insert a parabolic arc (C6) supported by the parabola y = -x^2 with // endpoints (-sqrt(3),-3) (~(-1.73,-3)) and (sqrt(2),-2) (~(1.41,-2)). // Since the x-coordinates of the endpoints cannot be acccurately represented, @@ -53,8 +58,12 @@ int main() { // is 1/2 (therefore its squared radius is 1/4) (C7). Rat_circle circ7(Rat_point(4, Rational(5,2)), Rational(1,4)); insert(arr, Conic_arc(circ7, CGAL::CLOCKWISE, Point(4, 3), Point(4, 2))); +#endif + print_arrangement_size(arr); + CGAL::draw(arr); + return 0; } @@ -62,8 +71,7 @@ int main() { #include -int main () -{ +int main() { std::cout << "Sorry, this example needs GMP and CORE\n"; return 0; } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h index e02e46e700a..a2fb69131fb 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h @@ -628,31 +628,31 @@ public: // Compute the x- and y-coordinates of intersection points of the base // conic and the k'th auxiliary conic. - n_xs = _compute_resultant_roots(nt_traits, - base_coeffs[0], base_coeffs[1], - base_coeffs[2], - base_coeffs[3], base_coeffs[4], - base_coeffs[5], - deg_base, - aux_coeffs[0], aux_coeffs[1], - aux_coeffs[2], - aux_coeffs[3], aux_coeffs[4], - aux_coeffs[5], - deg_aux, - xs); + n_xs = compute_resultant_roots(nt_traits, + base_coeffs[0], base_coeffs[1], + base_coeffs[2], + base_coeffs[3], base_coeffs[4], + base_coeffs[5], + deg_base, + aux_coeffs[0], aux_coeffs[1], + aux_coeffs[2], + aux_coeffs[3], aux_coeffs[4], + aux_coeffs[5], + deg_aux, + xs); - n_ys = _compute_resultant_roots(nt_traits, - base_coeffs[1], base_coeffs[0], - base_coeffs[2], - base_coeffs[4], base_coeffs[3], - base_coeffs[5], - deg_base, - aux_coeffs[1], aux_coeffs[0], - aux_coeffs[2], - aux_coeffs[4], aux_coeffs[3], - aux_coeffs[5], - deg_aux, - ys); + n_ys = compute_resultant_roots(nt_traits, + base_coeffs[1], base_coeffs[0], + base_coeffs[2], + base_coeffs[4], base_coeffs[3], + base_coeffs[5], + deg_base, + aux_coeffs[1], aux_coeffs[0], + aux_coeffs[2], + aux_coeffs[4], aux_coeffs[3], + aux_coeffs[5], + deg_aux, + ys); // Find the intersection point which is nearest the given approximation // and set it as the endpoint. @@ -667,8 +667,7 @@ public: nt_traits.convert(base_coeffs[4]) * ys[j] + nt_traits.convert(base_coeffs[5]); - if (CGAL::sign(val) != ZERO) - continue; + if (CGAL::sign(val) != ZERO) continue; val = nt_traits.convert(aux_coeffs[0]) * xs[i]*xs[i] + nt_traits.convert(aux_coeffs[1]) * ys[j]*ys[j] + @@ -749,7 +748,7 @@ public: // Duplicate the extra data, if necessary. m_extra_data = (arc.m_extra_data != nullptr) ? - new Extra_data(*(arc.m_extra_data)) ? nullptr; + new Extra_data(*(arc.m_extra_data)) : nullptr; return (*this); } @@ -764,12 +763,12 @@ public: /*! Get the coefficients of the underlying conic. */ - const Integer& r() const {return (m_r);} - const Integer& s() const {return (m_s);} - const Integer& t() const {return (m_t);} - const Integer& u() const {return (m_u);} - const Integer& v() const {return (m_v);} - const Integer& w() const {return (m_w);} + const Integer& r() const { return (m_r); } + const Integer& s() const { return (m_s); } + const Integer& t() const { return (m_t); } + const Integer& u() const { return (m_u); } + const Integer& v() const { return (m_v); } + const Integer& w() const { return (m_w); } /*! Check whether the arc is x-monotone. */ diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h index 79049ca3977..1ea27a61b22 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h @@ -8,7 +8,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein +// Author(s): Ron Wein #ifndef CGAL_CONIC_INTERSECTIONS_2_H #define CGAL_CONIC_INTERSECTIONS_2_H @@ -24,8 +24,7 @@ namespace CGAL { -/*! - * Compute the roots of the resultants of the two bivariate polynomials: +/*! Compute the roots of the resultants of the two bivariate polynomials: * C1: r1*x^2 + s1*y^2 + t1*xy + u1*x + v1*y + w1 = 0 * C2: r2*x^2 + s2*y^2 + t2*xy + u2*x + v2*y + w2 = 0 * \param deg1 The degree of the first curve. @@ -35,84 +34,76 @@ namespace CGAL { * \pre xs must be a vector of size 4. * \return The number of distinct roots found. */ -template -int - _compute_resultant_roots (Nt_traits& nt_traits, - const typename Nt_traits::Integer& r1, - const typename Nt_traits::Integer& s1, - const typename Nt_traits::Integer& t1, - const typename Nt_traits::Integer& u1, - const typename Nt_traits::Integer& v1, - const typename Nt_traits::Integer& w1, - const int& deg1, - const typename Nt_traits::Integer& r2, - const typename Nt_traits::Integer& s2, - const typename Nt_traits::Integer& t2, - const typename Nt_traits::Integer& u2, - const typename Nt_traits::Integer& v2, - const typename Nt_traits::Integer& w2, - const int& deg2, - typename Nt_traits::Algebraic *xs) +template +int compute_resultant_roots(Nt_traits& nt_traits, + const typename Nt_traits::Integer& r1, + const typename Nt_traits::Integer& s1, + const typename Nt_traits::Integer& t1, + const typename Nt_traits::Integer& u1, + const typename Nt_traits::Integer& v1, + const typename Nt_traits::Integer& w1, + const int& deg1, + const typename Nt_traits::Integer& r2, + const typename Nt_traits::Integer& s2, + const typename Nt_traits::Integer& t2, + const typename Nt_traits::Integer& u2, + const typename Nt_traits::Integer& v2, + const typename Nt_traits::Integer& w2, + const int& deg2, + typename Nt_traits::Algebraic* xs) { - if (deg1 == 2 && deg2 == 1) - { + if ((deg1 == 2) && (deg2 == 1)) { // If necessary, swap roles between the two curves, so that the first // curve always has the minimal degree. - return (_compute_resultant_roots (nt_traits, - r2, s2, t2, u2, v2, w2, - deg2, - r1, s1, t1, u1, v1, w1, - deg1, - xs)); + return (compute_resultant_roots(nt_traits, + r2, s2, t2, u2, v2, w2, + deg2, + r1, s1, t1, u1, v1, w1, + deg1, + xs)); } // Act according to the degree of the first conic curve. - const typename Nt_traits::Integer _two = 2; - typename Nt_traits::Integer c[5]; - unsigned int degree = 4; - typename Nt_traits::Algebraic *xs_end; + const typename Nt_traits::Integer two = 2; + typename Nt_traits::Integer c[5]; + unsigned int degree = 4; + typename Nt_traits::Algebraic* xs_end; - if (deg1 == 1) - { + if (deg1 == 1) { // The first curve has no quadratic coefficients, and represents a line. - if (CGAL::sign (v1) == ZERO) - { + if (CGAL::sign (v1) == ZERO) { // The first line is u1*x + w1 = 0, therefore: xs[0] = nt_traits.convert(-w1) / nt_traits.convert(u1); - return (1); + return 1; } // We can write the first curve as: y = -(u1*x + w1) / v1. - if (deg2 == 1) - { + if (deg2 == 1) { // The second curve is also a line. We therefore get the linear // equation c[1]*x + c[0] = 0: c[1] = v1*u2 - u1*v2; c[0] = v1*w2 - w1*v2; - if (CGAL::sign (c[1]) == ZERO) - // The two lines are parallel: - return (0); + // Return if the two lines are parallel + if (CGAL::sign (c[1]) == ZERO) return 0; - xs[0] = nt_traits.convert(-c[0]) / nt_traits.convert(c[1]); - return (1); + xs[0] = nt_traits.convert(-c[0]) / nt_traits.convert(c[1]); + return 1; } // We substitute this expression into the equation of the second // conic, and get the quadratic equation c[2]*x^2 + c[1]*x + c[0] = 0: c[2] = u1*u1*s2 - u1*v1*t2 + v1*v1*r2; - c[1] = _two*u1*w1*s2 - u1*v1*v2 - v1*w1*t2 + v1*v1*u2; + c[1] = two*u1*w1*s2 - u1*v1*v2 - v1*w1*t2 + v1*v1*u2; c[0] = w1*w1*s2 - v1*w1*v2 + v1*v1*w2; - xs_end = nt_traits.solve_quadratic_equation (c[2], c[1], c[0], - xs); + xs_end = nt_traits.solve_quadratic_equation(c[2], c[1], c[0], xs); return static_cast(xs_end - xs); } // At this stage, both curves have degree 2. We obtain a qaurtic polynomial // whose roots are the x-coordinates of the intersection points. - if (CGAL::sign (s1) == ZERO && CGAL::sign (s2) == ZERO) - { + if (CGAL::sign (s1) == ZERO && CGAL::sign (s2) == ZERO) { // If both s1 and s2 are zero, we can write the two curves as: // C1: (t1*x + v1)*y + (r1*x^2 + u1*x + w1) = 0 // C2: (t2*x + v2)*y + (r2*x^2 + u2*x + w2) = 0 @@ -125,41 +116,40 @@ int degree = 3; } - else - { + else { // We can write the two curves as: // C1: (s1)*y^2 + (t1*x + v1)*y + (r1*x^2 + u1*x + w1) = 0 // C2: (s2)*y^2 + (t2*x + v2)*y + (r2*x^2 + u2*x + w2) = 0 // By writing the resultant of these two polynomials we get a quartic // polynomial, whose coefficients are given by: - c[4] = -_two*s1*s2*r1*r2 + s1*t2*t2*r1 - s1*t2*t1*r2 + + c[4] = -two*s1*s2*r1*r2 + s1*t2*t2*r1 - s1*t2*t1*r2 + s1*s1*r2*r2 - s2*t1*r1*t2 + s2*t1*t1*r2 + s2*s2*r1*r1; c[3] = -t2*r1*v1*s2 - u2*t1*t2*s1 - v2*r1*t1*s2 - - r2*t1*v2*s1 - _two*s1*s2*r1*u2 - t2*u1*t1*s2 + u2*t1*t1*s2 - - r2*v1*t2*s1 + u1*t2*t2*s1 + _two*v2*r1*t2*s1 + _two*u2*r2*s1*s1 + - _two*r2*v1*t1*s2 + _two*u1*r1*s2*s2 - _two*s1*s2*u1*r2; + r2*t1*v2*s1 - two*s1*s2*r1*u2 - t2*u1*t1*s2 + u2*t1*t1*s2 - + r2*v1*t2*s1 + u1*t2*t2*s1 + two*v2*r1*t2*s1 + two*u2*r2*s1*s1 + + two*r2*v1*t1*s2 + two*u1*r1*s2*s2 - two*s1*s2*u1*r2; - c[2] = -r2*v1*v2*s1 + u2*u2*s1*s1 + _two*w2*r2*s1*s1 + - _two*u2*v1*t1*s2 - u2*v1*t2*s1 + w2*t1*t1*s2 - _two*s1*s2*u1*u2 - + c[2] = -r2*v1*v2*s1 + u2*u2*s1*s1 + two*w2*r2*s1*s1 + + two*u2*v1*t1*s2 - u2*v1*t2*s1 + w2*t1*t1*s2 - two*s1*s2*u1*u2 - w2*t1*t2*s1 + v2*v2*r1*s1 + u1*u1*s2*s2 - v2*r1*v1*s2 + - _two*w1*r1*s2*s2 - u2*t1*v2*s1 - t2*u1*v1*s2 - _two*s1*s2*r1*w2 - - _two*s1*s2*w1*r2 + r2*v1*v1*s2 + w1*t2*t2*s1 - v2*u1*t1*s2 - - t2*w1*t1*s2 + _two*v2*u1*t2*s1; + two*w1*r1*s2*s2 - u2*t1*v2*s1 - t2*u1*v1*s2 - two*s1*s2*r1*w2 - + two*s1*s2*w1*r2 + r2*v1*v1*s2 + w1*t2*t2*s1 - v2*u1*t1*s2 - + t2*w1*t1*s2 + two*v2*u1*t2*s1; - c[1] = _two*w2*u2*s1*s1 + _two*w2*v1*t1*s2 - w2*v1*t2*s1 + - _two*v2*w1*t2*s1 + _two*w1*u1*s2*s2 - v2*u1*v1*s2 - _two*s1*s2*u1*w2 - + c[1] = two*w2*u2*s1*s1 + two*w2*v1*t1*s2 - w2*v1*t2*s1 + + two*v2*w1*t2*s1 + two*w1*u1*s2*s2 - v2*u1*v1*s2 - two*s1*s2*u1*w2 - v2*w1*t1*s2 + u2*v1*v1*s2 - t2*w1*v1*s2 - w2*t1*v2*s1 + - v2*v2*u1*s1 - u2*v1*v2*s1 - _two*s1*s2*w1*u2; + v2*v2*u1*s1 - u2*v1*v2*s1 - two*s1*s2*w1*u2; c[0] = s2*v1*v1*w2 - s1*v2*v1*w2 - s2*v1*w1*v2 + s2*s2*w1*w1 - - _two*s1*s2*w1*w2 + s1*w1*v2*v2 + s1*s1*w2*w2; + two*s1*s2*w1*w2 + s1*w1*v2*v2 + s1*s1*w2*w2; degree = 4; } // Compute the roots of the resultant polynomial. - typename Nt_traits::Polynomial poly = + typename Nt_traits::Polynomial poly = nt_traits.construct_polynomial (c, degree); xs_end = nt_traits.compute_polynomial_roots (poly, @@ -167,8 +157,7 @@ int return static_cast(xs_end - xs); } -/*! - * Compute the roots of the resultants of the two bivariate polynomials: +/*! Compute the roots of the resultants of the two bivariate polynomials: * C1: r*x^2 + s*y^2 + t*xy + u*x + v*y + w = 0 * C2: A*x + B*y + C = 0 * \param deg1 The degree of the first curve. @@ -177,55 +166,50 @@ int * \pre xs must be a vector of size 4. * \return The number of distinct roots found. */ -template -int -_compute_resultant_roots (Nt_traits& nt_traits, - const typename Nt_traits::Algebraic& r, - const typename Nt_traits::Algebraic& s, - const typename Nt_traits::Algebraic& t, - const typename Nt_traits::Algebraic& u, - const typename Nt_traits::Algebraic& v, - const typename Nt_traits::Algebraic& w, - const int& deg1, - const typename Nt_traits::Algebraic& A, - const typename Nt_traits::Algebraic& B, - const typename Nt_traits::Algebraic& C, - typename Nt_traits::Algebraic *xs) +template +int compute_resultant_roots(Nt_traits& nt_traits, + const typename Nt_traits::Algebraic& r, + const typename Nt_traits::Algebraic& s, + const typename Nt_traits::Algebraic& t, + const typename Nt_traits::Algebraic& u, + const typename Nt_traits::Algebraic& v, + const typename Nt_traits::Algebraic& w, + const int& deg1, + const typename Nt_traits::Algebraic& A, + const typename Nt_traits::Algebraic& B, + const typename Nt_traits::Algebraic& C, + typename Nt_traits::Algebraic* xs) { - if (deg1 == 1) - { + if (deg1 == 1) { // We should actually compute the intersection of two line: // (u*x + v*y + w = 0) and (A*x + B*y + C = 0): - const typename Nt_traits::Algebraic denom = A*v - B*u; + const typename Nt_traits::Algebraic denom = A*v - B*u; - if (CGAL::sign (denom) == CGAL::ZERO) - // The two lines are parallel and do not intersect. - return (0); + // Return if the two lines are parallel and do not intersect. + if (CGAL::sign(denom) == CGAL::ZERO) return 0; xs[0] = (B*w - C*v) / denom; - return (1); + return 1; } - if (CGAL::sign (B) == CGAL::ZERO) - { + if (CGAL::sign(B) == CGAL::ZERO) { // The first line is A*x + C = 0, therefore: xs[0] = -C / A; - return (1); + return 1; } // We can write the first curve as: y = -(A*x + C) / B. // We substitute this expression into the equation of the conic, and get // the quadratic equation c[2]*x^2 + c[1]*x + c[0] = 0: - const typename Nt_traits::Algebraic _two = 2; - typename Nt_traits::Algebraic c[3]; - typename Nt_traits::Algebraic *xs_end; + const typename Nt_traits::Algebraic two = 2; + typename Nt_traits::Algebraic c[3]; + typename Nt_traits::Algebraic* xs_end; c[2] = A*A*s - A*B*t + B*B*r; - c[1] = _two*A*C*s - A*B*v - B*C*t + B*B*u; + c[1] = two*A*C*s - A*B*v - B*C*t + B*B*u; c[0] = C*C*s - B*C*v + B*B*w; - xs_end = nt_traits.solve_quadratic_equation (c[2], c[1], c[0], - xs); + xs_end = nt_traits.solve_quadratic_equation(c[2], c[1], c[0], xs); return static_cast(xs_end - xs); } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h index ad13fe00427..ecd98ee490f 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_x_monotone_arc_2.h @@ -50,37 +50,34 @@ public: typedef std::pair Intersection_point; typedef std::list Intersection_list; - using Conic_arc_2::_sign_of_extra_data; - using Conic_arc_2::_is_between_endpoints; - using Conic_arc_2::_is_strictly_between_endpoints; - using Conic_arc_2::_conic_get_y_coordinates; + using Conic_arc_2::sign_of_extra_data; + using Conic_arc_2::is_between_endpoints; + using Conic_arc_2::is_strictly_between_endpoints; + using Conic_arc_2::conic_get_y_coordinates; /*! * \struct Less functor for Conic_pair. */ struct Less_conic_pair { - bool operator()(const Conic_pair& cp1, const Conic_pair& cp2) const - { + bool operator()(const Conic_pair& cp1, const Conic_pair& cp2) const { // Compare the pairs of IDs lexicographically. return ((cp1.first < cp2.first) || ((cp1.first == cp2.first) && (cp1.second < cp2.second))); } }; - typedef std::map Intersection_map; + typedef std::map + Intersection_map; typedef typename Intersection_map::value_type Intersection_map_entry; typedef typename Intersection_map::iterator Intersection_map_iterator; protected: - typedef Conic_arc_2 Base; typedef typename Conic_arc_2::Integer Integer; typedef typename Conic_arc_2::Nt_traits Nt_traits; typedef typename Conic_arc_2::Rat_kernel Rat_kernel; - // Bit masks for the _info field (the two least significant bits are already + // Bit masks for the m_info field (the two least significant bits are already // used by the base class). enum { IS_VERTICAL_SEGMENT = 4, @@ -102,7 +99,7 @@ protected: Algebraic alg_v; // converted to algebraic numbers. Algebraic alg_w; // - Conic_id _id; // The ID number of the supporting conic curve. + Conic_id m_id; // The ID number of the supporting conic curve. public: @@ -114,7 +111,7 @@ public: */ _Conic_x_monotone_arc_2 () : Base(), - _id() + m_id() {} /*! @@ -129,7 +126,7 @@ public: alg_u(arc.alg_u), alg_v(arc.alg_v), alg_w(arc.alg_w), - _id(arc._id) + m_id(arc.m_id) {} /*! Construct an x-monotone arc from a conic arc. @@ -138,10 +135,10 @@ public: */ _Conic_x_monotone_arc_2(const Base& arc) : Base(arc), - _id() + m_id() { CGAL_precondition(arc.is_valid() && arc.is_x_monotone()); - _set (); + set(); } /*! Construct an x-monotone arc from a conic arc. @@ -150,10 +147,10 @@ public: */ _Conic_x_monotone_arc_2(const Base& arc, const Conic_id& id) : Base(arc), - _id(id) + m_id(id) { CGAL_precondition(arc.is_valid() && id.is_valid()); - _set (); + set(); } /*! Construct an x-monotone sub-arc from a conic arc. @@ -166,15 +163,15 @@ public: const Point_2& source, const Point_2& target, const Conic_id& id) : Base(arc), - _id(id) + m_id(id) { CGAL_precondition(arc.is_valid() && id.is_valid()); // Set the two endpoints. - this->_source = source; - this->_target = target; + this->m_source = source; + this->m_target = target; - _set(); + set(); } /*! Construct a special segment connecting to given endpoints (for the usage @@ -185,23 +182,22 @@ public: _Conic_x_monotone_arc_2(const Point_2& source, const Point_2& target) : Base(source, target) { - this->_info |= static_cast(DEGREE_1); + this->m_info |= static_cast(DEGREE_1); Alg_kernel ker; auto cmp_xy = ker.compare_xy_2_object(); - Comparison_result dir_res = cmp_xy(this->_source, this->_target); - if (dir_res == SMALLER) this->_info |= IS_DIRECTED_RIGHT; + Comparison_result dir_res = cmp_xy(this->m_source, this->m_target); + if (dir_res == SMALLER) this->m_info |= IS_DIRECTED_RIGHT; // Check if the segment is vertical. - if (CGAL::sign(this->_extra_data_P->b) == ZERO) - this->_info |= IS_VERTICAL_SEGMENT; + if (CGAL::sign(this->m_extra_data->b) == ZERO) + this->m_info |= IS_VERTICAL_SEGMENT; // Mark that this is a special segment. - this->_info |= IS_SPECIAL_SEGMENT; + this->m_info |= IS_SPECIAL_SEGMENT; } - /*! - * Construct a special segment of a given line connecting to given + /*! Construct a special segment of a given line connecting to given * endpoints. * \param a, b, c The coefficients of the supporting line (ax + by + c = 0). * \param source The source point. @@ -214,52 +210,53 @@ public: Base() { // Make sure the two endpoints lie on the supporting line. - CGAL_precondition(CGAL::sign(a * source.x() + - b * source.y() + c) == CGAL::ZERO); + CGAL_precondition + (CGAL::sign(a * source.x() + b * source.y() + c) == CGAL::ZERO); - CGAL_precondition(CGAL::sign(a * target.x() + - b * target.y() + c) == CGAL::ZERO); + CGAL_precondition + (CGAL::sign(a * target.x() + b * target.y() + c) == CGAL::ZERO); - // Set the basic properties and clear the _info bits. - this->_source = source; - this->_target = target; - this->_orient = COLLINEAR; - this->_info = 0; + // Set the basic properties and clear the m_info bits. + this->m_source = source; + this->m_target = target; + this->m_orient = COLLINEAR; + this->m_info = 0; // Check if the arc is directed right (the target is lexicographically // greater than the source point), or to the left. Alg_kernel ker; Comparison_result res = - ker.compare_x_2_object()(this->_source, this->_target); + ker.compare_x_2_object()(this->m_source, this->m_target); - this->_info = (static_cast(Conic_arc_2::IS_VALID) | static_cast(DEGREE_1)); + this->m_info = + (static_cast(Conic_arc_2::IS_VALID) | static_cast(DEGREE_1)); if (res == EQUAL) { // Mark that the segment is vertical. - this->_info = (this->_info | IS_VERTICAL_SEGMENT); + this->m_info = (this->m_info | IS_VERTICAL_SEGMENT); // Compare the endpoints lexicographically. - res = ker.compare_y_2_object()(this->_source, this->_target); + res = ker.compare_y_2_object()(this->m_source, this->m_target); CGAL_precondition (res != EQUAL); if (res == EQUAL) { // Invalid arc: - this->_info = 0; + this->m_info = 0; return; } } if (res == SMALLER) - this->_info = (this->_info | IS_DIRECTED_RIGHT); + this->m_info = (this->m_info | IS_DIRECTED_RIGHT); // Store the coefficients of the line. - this->_extra_data_P = new typename Base::Extra_data; - this->_extra_data_P->a = a; - this->_extra_data_P->b = b; - this->_extra_data_P->c = c; - this->_extra_data_P->side = ZERO; + this->m_extra_data = new typename Base::Extra_data; + this->m_extra_data->a = a; + this->m_extra_data->b = b; + this->m_extra_data->c = c; + this->m_extra_data->side = ZERO; // Mark that this is a special segment. - this->_info = (this->_info | IS_SPECIAL_SEGMENT); + this->m_info = (this->m_info | IS_SPECIAL_SEGMENT); return; } @@ -268,8 +265,7 @@ public: * Assignment operator. * \param arc The copied arc. */ - const Self& operator=(const Self& arc) - { + const Self& operator=(const Self& arc) { CGAL_precondition (arc.is_valid()); if (this == &arc) return (*this); @@ -285,7 +281,7 @@ public: alg_v = arc.alg_v; alg_w = arc.alg_w; - _id = arc._id; + m_id = arc.m_id; return (*this); } @@ -297,51 +293,49 @@ public: /*! * Get the coefficients of the underlying conic. */ - const Integer& r() const { return (this->_r); } - const Integer& s() const { return (this->_s); } - const Integer& t() const { return (this->_t); } - const Integer& u() const { return (this->_u); } - const Integer& v() const { return (this->_v); } - const Integer& w() const { return (this->_w); } + const Integer& r() const { return (this->m_r); } + const Integer& s() const { return (this->m_s); } + const Integer& t() const { return (this->m_t); } + const Integer& u() const { return (this->m_u); } + const Integer& v() const { return (this->m_v); } + const Integer& w() const { return (this->m_w); } /*! * Get the arc's source. * \return The source point. */ - const Conic_point_2& source() const { return (this->_source); } + const Conic_point_2& source() const { return (this->m_source); } /*! Get the arc's target. * \return The target point. */ - const Conic_point_2& target() const { return (this->_target); } + const Conic_point_2& target() const { return (this->m_target); } /*! Get the orientation of the arc. * \return The orientation. */ - Orientation orientation() const { return (this->_orient); } + Orientation orientation() const { return (this->m_orient); } /*! Get the left endpoint of the arc. */ - const Conic_point_2& left () const - { - if ((this->_info & IS_DIRECTED_RIGHT) != 0) return (this->_source); - else return (this->_target); + const Conic_point_2& left() const { + if ((this->m_info & IS_DIRECTED_RIGHT) != 0) return (this->m_source); + else return (this->m_target); } - /*! - * Get the right endpoint of the arc. + /*! Get the right endpoint of the arc. */ - const Conic_point_2& right () const + const Conic_point_2& right() const { - if ((this->_info & IS_DIRECTED_RIGHT) != 0) return (this->_target); - else return (this->_source); + if ((this->m_info & IS_DIRECTED_RIGHT) != 0) return (this->m_target); + else return (this->m_source); } /*! * Return true iff the conic arc is directed right iexicographically. */ bool is_directed_right() const - { return ((this->_info & IS_DIRECTED_RIGHT) != 0); } + { return ((this->m_info & IS_DIRECTED_RIGHT) != 0); } /*! * Get a bounding box for the conic arc. @@ -356,76 +350,67 @@ public: /*! * Check if the conic arc is a vertical segment. */ - bool is_vertical () const - { - return ((this->_info & IS_VERTICAL_SEGMENT) != 0); - } + bool is_vertical() const + { return ((this->m_info & IS_VERTICAL_SEGMENT) != 0); } /*! * Check whether the given point lies on the arc. * \param p The qury point. * \param (true) if p lies on the arc; (false) otherwise. */ - bool contains_point(const Conic_point_2& p) const - { + bool contains_point(const Conic_point_2& p) const { // First check if p lies on the supporting conic. We first check whether // it is one of p's generating conic curves. - bool p_on_conic = false; + bool p_on_conic = false; - if (p.is_generating_conic(_id)) { + if (p.is_generating_conic(m_id)) { p_on_conic = true; } else { // Check whether p satisfies the supporting conic equation. - p_on_conic = _is_on_supporting_conic(p.x(), p.y()); + p_on_conic = is_on_supporting_conic(p.x(), p.y()); if (p_on_conic) { // As p lies on the supporting conic of our arc, add its ID to // the list of generating conics for p. - Conic_point_2& p_non_const = const_cast (p); - p_non_const.set_generating_conic (_id); + Conic_point_2& p_non_const = const_cast(p); + p_non_const.set_generating_conic(m_id); } } - if (! p_on_conic) - return (false); + if (! p_on_conic) return (false); // Check if p is between the endpoints of the arc. - return (_is_between_endpoints (p)); + return is_between_endpoints(p); } //@} /// \name Constructing points on the arc. //@{ - /*! - * Compute a point on the arc with the same x-coordiante as the given point. + /*! Compute a point on the arc with the same x-coordiante as the given point. * \param p The given point. * \pre The arc is not vertical and p is in the x-range of the arc. * \return A point on the arc with the same x-coordiante as p. */ - Point_2 point_at_x (const Point_2& p) const - { + Point_2 point_at_x(const Point_2& p) const { // Make sure that p is in the x-range of the arc. - CGAL_precondition ((this->_info & IS_VERTICAL_SEGMENT) == 0); + CGAL_precondition((this->m_info & IS_VERTICAL_SEGMENT) == 0); - CGAL_precondition_code ( - Alg_kernel ker; - ); + CGAL_precondition_code(Alg_kernel ker;); CGAL_precondition(ker.compare_x_2_object() (p, left()) != SMALLER && ker.compare_x_2_object() (p, right()) != LARGER); - if (_is_special_segment()) { + if (is_special_segment()) { // In case of a special segment, the equation of the supported line // (a*x + b*y + c) = 0 is stored with the extra data field, and we // simply have: - Algebraic _y = -(this->_extra_data_P->a*p.x() + - this->_extra_data_P->c) / - this->_extra_data_P->b; + Algebraic _y = -(this->m_extra_data->a*p.x() + this->m_extra_data->c) / + this->m_extra_data->b; // Return the computed point. - return (Point_2 (p.x(), _y)); + return Point_2 (p.x(), _y); } // Compute the y-coordinate according to the degree of the supporting @@ -433,22 +418,22 @@ public: Nt_traits nt_traits; Algebraic y; - if ((this->_info & DEGREE_MASK) == DEGREE_1) { + if ((this->m_info & DEGREE_MASK) == DEGREE_1) { // In case of a linear curve, the y-coordinate is a simple linear // expression of x(p) (note that v is not 0 as the arc is not vertical): // y = -(u*x(p) + w) / v y = -(alg_u*p.x() + alg_w) / alg_v; } - else if (this->_orient == COLLINEAR) { - CGAL_assertion (this->_extra_data_P != nullptr); + else if (this->m_orient == COLLINEAR) { + CGAL_assertion (this->m_extra_data != nullptr); // In this case the equation of the supporting line is given by the // extra data structure. - y = -(this->_extra_data_P->a * p.x() + - this->_extra_data_P->c) / this->_extra_data_P->b; + y = -(this->m_extra_data->a * p.x() + + this->m_extra_data->c) / this->m_extra_data->b; } else { - CGAL_assertion((this->_info & DEGREE_MASK) == DEGREE_2); + CGAL_assertion((this->m_info & DEGREE_MASK) == DEGREE_2); // In this case the y-coordinate is one of solutions to the quadratic // equation: @@ -457,7 +442,7 @@ public: Algebraic B = alg_t*p.x() + alg_v; Algebraic C = (alg_r*p.x() + alg_u)*p.x() + alg_w; - if (CGAL::sign(this->_s) == ZERO) { + if (CGAL::sign(this->m_s) == ZERO) { // In this case A is 0 and we have a linear equation. CGAL_assertion (CGAL::sign (B) != ZERO); @@ -471,7 +456,7 @@ public: // We take either the root involving -sqrt(disc) or +sqrt(disc) // based on the information flags. - if ((this->_info & PLUS_SQRT_DISC_ROOT) != 0) { + if ((this->m_info & PLUS_SQRT_DISC_ROOT) != 0) { y = (nt_traits.sqrt (disc) - B) / (2*A); } else { @@ -481,11 +466,10 @@ public: } // Return the computed point. - return (Point_2 (p.x(), y)); + return Point_2(p.x(), y); } - /*! - * Get a polyline approximating the conic arc. + /*! Get a polyline approximating the conic arc. * \param n The maximal number of sample points. * \param oi An output iterator, whose value-type is pair * (representing an approximated point). @@ -494,10 +478,8 @@ public: * (p_0, p_1, ..., p_n), where p_0 and p_n are the left and right * endpoints of the arc, respectively. */ - template - OutputIterator polyline_approximation (size_t n, - OutputIterator oi) const - { + template + OutputIterator polyline_approximation(size_t n, OutputIterator oi) const { CGAL_precondition (n != 0); const double x_left = CGAL::to_double (left().x()); @@ -505,7 +487,7 @@ public: const double x_right = CGAL::to_double (right().x()); const double y_right = CGAL::to_double (right().y()); - if (this->_orient == COLLINEAR) { + if (this->m_orient == COLLINEAR) { // In case of a line segment, return the two endpoints. *oi++ = std::pair (x_left, y_left); *oi++ = std::pair (x_right, y_right); @@ -513,46 +495,37 @@ public: } // Otherwise, sample (n - 1) equally-spaced points in between. - const double app_r = CGAL::to_double (this->_r); - const double app_s = CGAL::to_double (this->_s); - const double app_t = CGAL::to_double (this->_t); - const double app_u = CGAL::to_double (this->_u); - const double app_v = CGAL::to_double (this->_v); - const double app_w = CGAL::to_double (this->_w); + const double app_r = CGAL::to_double (this->m_r); + const double app_s = CGAL::to_double (this->m_s); + const double app_t = CGAL::to_double (this->m_t); + const double app_u = CGAL::to_double (this->m_u); + const double app_v = CGAL::to_double (this->m_v); + const double app_w = CGAL::to_double (this->m_w); const double x_jump = (x_right - x_left) / n; - double x, y; - const bool A_is_zero = (CGAL::sign(this->_s) == ZERO); - double A = app_s, B, C; - double disc; - size_t i; + double x, y; + const bool A_is_zero = (CGAL::sign(this->m_s) == ZERO); + double A = app_s, B, C; + double disc; + size_t i; - *oi = std::pair(x_left, y_left); // The left point. - ++oi; - for (i = 1; i < n; i++) { + *oi++ = std::pair(x_left, y_left); // The left point. + for (i = 1; i < n; ++i) { x = x_left + x_jump*i; // Solve the quadratic equation: A*x^2 + B*x + C = 0: B = app_t*x + app_v; C = (app_r*x + app_u)*x + app_w; - if (A_is_zero) { - y = -C / B; - } + if (A_is_zero) y = -C / B; else { disc = B*B - 4*A*C; - if (disc < 0) disc = 0; // We take either the root involving -sqrt(disc) or +sqrt(disc) // based on the information flags. - if ((this->_info & PLUS_SQRT_DISC_ROOT) != 0) { - y = (std::sqrt(disc) - B) / (2*A); - } - else { - y = -(B + std::sqrt (disc)) / (2*A); - } + y = ((this->m_info & PLUS_SQRT_DISC_ROOT) != 0) ? + (std::sqrt(disc) - B) / (2*A) : -(B + std::sqrt (disc)) / (2*A); } - *oi++ = std::pair (x, y); } *oi++ = std::pair (x_right, y_right); // The right point. @@ -566,23 +539,23 @@ public: * \return The relative position of the arcs to the right of p. * \pre Both arcs we compare are not vertical segments. */ - Comparison_result compare_to_right(const Self& arc, - const Conic_point_2& p) const + Comparison_result compare_to_right(const Self& arc, const Conic_point_2& p) + const { - CGAL_precondition((this->_info & IS_VERTICAL_SEGMENT) == 0 && - (arc._info & IS_VERTICAL_SEGMENT) == 0); + CGAL_precondition((this->m_info & IS_VERTICAL_SEGMENT) == 0 && + (arc.m_info & IS_VERTICAL_SEGMENT) == 0); // In case one arc is facing upwards and another facing downwards, it is // clear that the one facing upward is above the one facing downwards. - if (_has_same_supporting_conic (arc)) { - if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) + if (has_same_supporting_conic (arc)) { + if ((this->m_info & FACING_UP) != 0 && (arc.m_info & FACING_DOWN) != 0) return LARGER; - else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) + else if ((this->m_info & FACING_DOWN) != 0 && (arc.m_info & FACING_UP) != + 0) return SMALLER; // In this case the two arcs overlap. - CGAL_assertion((this->_info & FACING_MASK) == (arc._info & FACING_MASK)); - + CGAL_assertion((this->m_info & FACING_MASK) == (arc.m_info & FACING_MASK)); return EQUAL; } @@ -591,14 +564,14 @@ public: Algebraic slope1_numer, slope1_denom; Algebraic slope2_numer, slope2_denom; - _derive_by_x_at (p, 1, slope1_numer, slope1_denom); - arc._derive_by_x_at (p, 1, slope2_numer, slope2_denom); + derive_by_x_at(p, 1, slope1_numer, slope1_denom); + arc.derive_by_x_at(p, 1, slope2_numer, slope2_denom); // Check if any of the slopes is vertical. const bool is_vertical_slope1 = (CGAL::sign(slope1_denom) == ZERO); const bool is_vertical_slope2 = (CGAL::sign(slope2_denom) == ZERO); - if (!is_vertical_slope1 && !is_vertical_slope2) { + if (! is_vertical_slope1 && !is_vertical_slope2) { // The two derivatives at p are well-defined: use them to determine // which arc is above the other (the one with a larger slope is below). Comparison_result slope_res = @@ -607,8 +580,8 @@ public: if (slope_res != EQUAL) return (slope_res); // Use the second-order derivative. - _derive_by_x_at(p, 2, slope1_numer, slope1_denom); - arc._derive_by_x_at(p, 2, slope2_numer, slope2_denom); + derive_by_x_at(p, 2, slope1_numer, slope1_denom); + arc.derive_by_x_at(p, 2, slope2_numer, slope2_denom); slope_res = CGAL::compare(slope1_numer*slope2_denom, slope2_numer*slope1_denom); @@ -616,45 +589,45 @@ public: if (slope_res != EQUAL) return (slope_res); // Use the third-order derivative. - _derive_by_x_at(p, 3, slope1_numer, slope1_denom); - arc._derive_by_x_at(p, 3, slope2_numer, slope2_denom); + derive_by_x_at(p, 3, slope1_numer, slope1_denom); + arc.derive_by_x_at(p, 3, slope2_numer, slope2_denom); slope_res = CGAL::compare(slope1_numer*slope2_denom, slope2_numer*slope1_denom); // \todo Handle higher-order derivatives: - CGAL_assertion (slope_res != EQUAL); + CGAL_assertion(slope_res != EQUAL); - return (slope_res); + return slope_res; } - else if (!is_vertical_slope2) { + else if ( !is_vertical_slope2) { // The first arc has a vertical slope at p: check whether it is // facing upwards or downwards and decide accordingly. - CGAL_assertion ((this->_info & FACING_MASK) != 0); + CGAL_assertion ((this->m_info & FACING_MASK) != 0); - if ((this->_info & FACING_UP) != 0) return (LARGER); + if ((this->m_info & FACING_UP) != 0) return LARGER; return SMALLER; } - else if (!is_vertical_slope1) { + else if (! is_vertical_slope1) { // The second arc has a vertical slope at p_int: check whether it is // facing upwards or downwards and decide accordingly. - CGAL_assertion ((arc._info & FACING_MASK) != 0); + CGAL_assertion ((arc.m_info & FACING_MASK) != 0); - if ((arc._info & FACING_UP) != 0) return (SMALLER); + if ((arc.m_info & FACING_UP) != 0) return SMALLER; return LARGER; } // The two arcs have vertical slopes at p_int: // First check whether one is facing up and one down. In this case the // comparison result is trivial. - if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) + if ((this->m_info & FACING_UP) != 0 && (arc.m_info & FACING_DOWN) != 0) return (LARGER); - else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) + else if ((this->m_info & FACING_DOWN) != 0 && (arc.m_info & FACING_UP) != 0) return SMALLER; // Compute the second-order derivative by y and act according to it. - _derive_by_y_at (p, 2, slope1_numer, slope1_denom); - arc._derive_by_y_at (p, 2, slope2_numer, slope2_denom); + derive_by_y_at (p, 2, slope1_numer, slope1_denom); + arc.derive_by_y_at (p, 2, slope2_numer, slope2_denom); Comparison_result slope_res = CGAL::compare(slope1_numer*slope2_denom, slope2_numer*slope1_denom); @@ -662,8 +635,8 @@ public: // If necessary, use the third-order derivative by y. if (slope_res == EQUAL) { // \todo Check this! - _derive_by_y_at(p, 3, slope1_numer, slope1_denom); - arc._derive_by_y_at(p, 3, slope2_numer, slope2_denom); + derive_by_y_at(p, 3, slope1_numer, slope1_denom); + arc.derive_by_y_at(p, 3, slope2_numer, slope2_denom); slope_res = CGAL::compare(slope2_numer*slope1_denom, slope1_numer*slope2_denom); @@ -672,37 +645,37 @@ public: // \todo Handle higher-order derivatives: CGAL_assertion(slope_res != EQUAL); - if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_UP) != 0) { + if ((this->m_info & FACING_UP) != 0 && (arc.m_info & FACING_UP) != 0) { // Both are facing up. return ((slope_res == LARGER) ? SMALLER : LARGER); } // Both are facing down. - return (slope_res); + return slope_res; } - /*! - * Compare to arcs immediately to the leftt of their intersection point. + /*! Compare to arcs immediately to the leftt of their intersection point. * \param arc The compared arc. * \param p The reference intersection point. * \return The relative position of the arcs to the left of p. * \pre Both arcs we compare are not vertical segments. */ - Comparison_result compare_to_left(const Self& arc, - const Conic_point_2& p) const + Comparison_result compare_to_left(const Self& arc, const Conic_point_2& p) + const { - CGAL_precondition((this->_info & IS_VERTICAL_SEGMENT) == 0 && - (arc._info & IS_VERTICAL_SEGMENT) == 0); + CGAL_precondition((this->m_info & IS_VERTICAL_SEGMENT) == 0 && + (arc.m_info & IS_VERTICAL_SEGMENT) == 0); // In case one arc is facing upwards and another facing downwards, it is // clear that the one facing upward is above the one facing downwards. - if (_has_same_supporting_conic (arc)) { - if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) + if (has_same_supporting_conic (arc)) { + if ((this->m_info & FACING_UP) != 0 && (arc.m_info & FACING_DOWN) != 0) return LARGER; - else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) + else if ((this->m_info & FACING_DOWN) != 0 && (arc.m_info & FACING_UP) != + 0) return SMALLER; // In this case the two arcs overlap. - CGAL_assertion((this->_info & FACING_MASK) == (arc._info & FACING_MASK)); + CGAL_assertion((this->m_info & FACING_MASK) == (arc.m_info & FACING_MASK)); return EQUAL; } @@ -712,70 +685,70 @@ public: Algebraic slope1_numer, slope1_denom; Algebraic slope2_numer, slope2_denom; - _derive_by_x_at(p, 1, slope1_numer, slope1_denom); - arc._derive_by_x_at(p, 1, slope2_numer, slope2_denom); + derive_by_x_at(p, 1, slope1_numer, slope1_denom); + arc.derive_by_x_at(p, 1, slope2_numer, slope2_denom); // Check if any of the slopes is vertical. const bool is_vertical_slope1 = (CGAL::sign (slope1_denom) == ZERO); const bool is_vertical_slope2 = (CGAL::sign (slope2_denom) == ZERO); - if (!is_vertical_slope1 && !is_vertical_slope2) { + if (! is_vertical_slope1 && !is_vertical_slope2) { // The two derivatives at p are well-defined: use them to determine // which arc is above the other (the one with a larger slope is below). - Comparison_result slope_res = CGAL::compare(slope2_numer*slope1_denom, - slope1_numer*slope2_denom); + Comparison_result slope_res = CGAL::compare(slope2_numer*slope1_denom, + slope1_numer*slope2_denom); if (slope_res != EQUAL) return (slope_res); // Use the second-order derivative. - _derive_by_x_at (p, 2, slope1_numer, slope1_denom); - arc._derive_by_x_at (p, 2, slope2_numer, slope2_denom); + derive_by_x_at (p, 2, slope1_numer, slope1_denom); + arc.derive_by_x_at (p, 2, slope2_numer, slope2_denom); - slope_res = CGAL::compare (slope1_numer*slope2_denom, - slope2_numer*slope1_denom); + slope_res = CGAL::compare(slope1_numer*slope2_denom, + slope2_numer*slope1_denom); if (slope_res != EQUAL) return (slope_res); // Use the third-order derivative. - _derive_by_x_at(p, 3, slope1_numer, slope1_denom); - arc._derive_by_x_at(p, 3, slope2_numer, slope2_denom); + derive_by_x_at(p, 3, slope1_numer, slope1_denom); + arc.derive_by_x_at(p, 3, slope2_numer, slope2_denom); slope_res = CGAL::compare(slope2_numer*slope1_denom, slope1_numer*slope2_denom); // \todo Handle higher-order derivatives: - CGAL_assertion (slope_res != EQUAL); + CGAL_assertion(slope_res != EQUAL); return (slope_res); } - else if (!is_vertical_slope2) { + else if (! is_vertical_slope2) { // The first arc has a vertical slope at p: check whether it is // facing upwards or downwards and decide accordingly. - CGAL_assertion ((this->_info & FACING_MASK) != 0); + CGAL_assertion ((this->m_info & FACING_MASK) != 0); - if ((this->_info & FACING_UP) != 0) return (LARGER); + if ((this->m_info & FACING_UP) != 0) return LARGER; return SMALLER; } - else if (!is_vertical_slope1) { + else if (! is_vertical_slope1) { // The second arc has a vertical slope at p_int: check whether it is // facing upwards or downwards and decide accordingly. - CGAL_assertion ((arc._info & FACING_MASK) != 0); + CGAL_assertion((arc.m_info & FACING_MASK) != 0); - if ((arc._info & FACING_UP) != 0) return (SMALLER); + if ((arc.m_info & FACING_UP) != 0) return SMALLER; return LARGER; } // The two arcs have vertical slopes at p_int: // First check whether one is facing up and one down. In this case the // comparison result is trivial. - if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_DOWN) != 0) + if ((this->m_info & FACING_UP) != 0 && (arc.m_info & FACING_DOWN) != 0) return LARGER; - else if ((this->_info & FACING_DOWN) != 0 && (arc._info & FACING_UP) != 0) + else if ((this->m_info & FACING_DOWN) != 0 && (arc.m_info & FACING_UP) != 0) return SMALLER; // Compute the second-order derivative by y and act according to it. - _derive_by_y_at(p, 2, slope1_numer, slope1_denom); - arc._derive_by_y_at(p, 2, slope2_numer, slope2_denom); + derive_by_y_at(p, 2, slope1_numer, slope1_denom); + arc.derive_by_y_at(p, 2, slope2_numer, slope2_denom); Comparison_result slope_res = CGAL::compare(slope2_numer*slope1_denom, slope1_numer*slope2_denom); @@ -783,8 +756,8 @@ public: // If necessary, use the third-order derivative by y. if (slope_res == EQUAL) { // \todo Check this! - _derive_by_y_at(p, 3, slope1_numer, slope1_denom); - arc._derive_by_y_at(p, 3, slope2_numer, slope2_denom); + derive_by_y_at(p, 3, slope1_numer, slope1_denom); + arc.derive_by_y_at(p, 3, slope2_numer, slope2_denom); slope_res = CGAL::compare(slope2_numer*slope1_denom, slope1_numer*slope2_denom); @@ -793,7 +766,7 @@ public: // \todo Handle higher-order derivatives: CGAL_assertion(slope_res != EQUAL); - if ((this->_info & FACING_UP) != 0 && (arc._info & FACING_UP) != 0) { + if ((this->m_info & FACING_UP) != 0 && (arc.m_info & FACING_UP) != 0) { // Both are facing up. return ((slope_res == LARGER) ? SMALLER : LARGER); } @@ -801,25 +774,23 @@ public: return (slope_res); } - /*! - * Compute the intersections with the given arc. + /*! Compute the intersections with the given arc. * \param arc The given intersecting arc. * \param inter_map Maps conic pairs to lists of their intersection points. * \param oi The output iterator. * \return The past-the-end iterator. */ template - OutputIterator intersect(const Self& arc, - Intersection_map& inter_map, + OutputIterator intersect(const Self& arc, Intersection_map& inter_map, OutputIterator oi) const { typedef boost::variant Intersection_result; - if (_has_same_supporting_conic(arc)) { + if (has_same_supporting_conic(arc)) { // Check for overlaps between the two arcs. Self overlap; - if (_compute_overlap(arc, overlap)) { + if (compute_overlap(arc, overlap)) { // There can be just a single overlap between two x-monotone arcs: *oi++ = Intersection_result(overlap); return oi; @@ -830,7 +801,7 @@ public: // an end point. // Note that in this case we do not define the multiplicity of the // intersection points we report. - Alg_kernel ker; + Alg_kernel ker; if (ker.equal_2_object()(left(), arc.left())) { Intersection_point ip(left(), 0); @@ -853,10 +824,10 @@ public: Intersection_list inter_list; bool invalid_ids = false; - if (_id.is_valid() && arc._id.is_valid()) { - if (_id < arc._id) conic_pair = Conic_pair (_id, arc._id); - else conic_pair = Conic_pair (arc._id, _id); - map_iter = inter_map.find (conic_pair); + if (m_id.is_valid() && arc.m_id.is_valid()) { + if (m_id < arc.m_id) conic_pair = Conic_pair(m_id, arc.m_id); + else conic_pair = Conic_pair(arc.m_id, m_id); + map_iter = inter_map.find(conic_pair); } else { // In case one of the IDs is invalid, we do not look in the map neither @@ -868,7 +839,7 @@ public: if (map_iter == inter_map.end()) { // In case the intersection points between the supporting conics have // not been computed before, compute them now and store them in the map. - _intersect_supporting_conics(arc, inter_list); + intersect_supporting_conics(arc, inter_list); if (! invalid_ids) inter_map[conic_pair] = inter_list; } @@ -880,8 +851,8 @@ public: // Go over the list of intersection points and report those that lie on // both x-monotone arcs. for (auto iter = inter_list.begin(); iter != inter_list.end(); ++iter) { - if (_is_between_endpoints((*iter).first) && - arc._is_between_endpoints((*iter).first)) + if (is_between_endpoints((*iter).first) && + arc.is_between_endpoints((*iter).first)) { *oi++ = Intersection_result(*iter); } @@ -894,156 +865,142 @@ public: /// \name Constructing x-monotone arcs. //@{ - /*! - * Split the arc into two at a given split point. + /*! Split the arc into two at a given split point. * \param p The split point. * \param c1 Output: The first resulting arc, lying to the left of p. * \param c2 Output: The first resulting arc, lying to the right of p. * \pre p lies in the interior of the arc (not one of its endpoints). */ - void split(const Conic_point_2& p, Self& c1, Self& c2) const - { + void split(const Conic_point_2& p, Self& c1, Self& c2) const { // Make sure that p lies on the interior of the arc. CGAL_precondition_code(Alg_kernel ker); - CGAL_precondition (this->contains_point (p) && - ! ker.equal_2_object() (p, this->_source) && - ! ker.equal_2_object() (p, this->_target)); + CGAL_precondition(this->contains_point (p) && + ! ker.equal_2_object()(p, this->m_source) && + ! ker.equal_2_object()(p, this->m_target)); // Make copies of the current arc. c1 = *this; c2 = *this; // Assign the endpoints of the arc. - if ((this->_info & IS_DIRECTED_RIGHT) != 0) - { + if ((this->m_info & IS_DIRECTED_RIGHT) != 0) { // The arc is directed from left to right, so p becomes c1's target // and c2's source. - c1._target = p; - c2._source = p; + c1.m_target = p; + c2.m_source = p; - if (! p.is_generating_conic (_id)) { - c1._target.set_generating_conic (_id); - c2._source.set_generating_conic (_id); + if (! p.is_generating_conic(m_id)) { + c1.m_target.set_generating_conic(m_id); + c2.m_source.set_generating_conic(m_id); } } - else - { + else { // The arc is directed from right to left, so p becomes c2's target // and c1's source. - c1._source = p; - c2._target = p; + c1.m_source = p; + c2.m_target = p; - if (! p.is_generating_conic (_id)) { - c1._source.set_generating_conic (_id); - c2._target.set_generating_conic (_id); + if (! p.is_generating_conic(m_id)) { + c1.m_source.set_generating_conic(m_id); + c2.m_target.set_generating_conic(m_id); } } - - return; } - /*! - * Flip the arc. + /*! Flip the arc. * \return An arc with swapped source and target and a reverse orienation. */ - Self flip() const - { + Self flip() const { // Make a copy of the current arc. Self arc = *this; // Reverse the orientation. - if (this->_orient == CLOCKWISE) arc._orient = COUNTERCLOCKWISE; - else if (this->_orient == COUNTERCLOCKWISE) arc._orient = CLOCKWISE; + if (this->m_orient == CLOCKWISE) arc.m_orient = COUNTERCLOCKWISE; + else if (this->m_orient == COUNTERCLOCKWISE) arc.m_orient = CLOCKWISE; // Swap the source and the target. - arc._source = this->_target; - arc._target = this->_source; + arc.m_source = this->m_target; + arc.m_target = this->m_source; // Change the direction bit among the information flags. - arc._info = (this->_info ^ IS_DIRECTED_RIGHT); + arc.m_info = (this->m_info ^ IS_DIRECTED_RIGHT); return arc; } - /*! - * Trim the arc given its new endpoints. + /*! Trim the arc given its new endpoints. * \param ps The new source point. * \param pt The new target point. * \return The new trimmed arc. * \pre Both ps and pt lies on the arc and must conform with the current * direction of the arc. */ - Self trim(const Conic_point_2& ps, const Conic_point_2& pt) const - { + Self trim(const Conic_point_2& ps, const Conic_point_2& pt) const { // Make sure that both ps and pt lie on the arc. CGAL_precondition(this->contains_point (ps) && this->contains_point (pt)); // Make sure that the endpoints conform with the direction of the arc. - Self arc = *this; - Alg_kernel ker; + Self arc = *this; + Alg_kernel ker; - if (! ((((this->_info & IS_DIRECTED_RIGHT) != 0) && + if (! ((((this->m_info & IS_DIRECTED_RIGHT) != 0) && ker.compare_xy_2_object() (ps, pt) == SMALLER) || - (((this->_info & IS_DIRECTED_RIGHT) == 0) && + (((this->m_info & IS_DIRECTED_RIGHT) == 0) && ker.compare_xy_2_object() (ps, pt) == LARGER))) { // We are allowed to change the direction only in case of a segment. - CGAL_assertion (this->_orient == COLLINEAR); - arc._info = (this->_info ^ IS_DIRECTED_RIGHT); + CGAL_assertion (this->m_orient == COLLINEAR); + arc.m_info = (this->m_info ^ IS_DIRECTED_RIGHT); } // Make a copy of the current arc and assign its endpoints. - if (! ker.equal_2_object() (ps, this->_source)) { - arc._source = ps; + if (! ker.equal_2_object()(ps, this->m_source)) { + arc.m_source = ps; - if (! ps.is_generating_conic (_id)) - arc._source.set_generating_conic (_id); + if (! ps.is_generating_conic(m_id)) + arc.m_source.set_generating_conic(m_id); } - if (! ker.equal_2_object() (pt, this->_target)) - { - arc._target = pt; + if (! ker.equal_2_object()(pt, this->m_target)) { + arc.m_target = pt; - if (! pt.is_generating_conic (_id)) - arc._target.set_generating_conic (_id); + if (! pt.is_generating_conic(m_id)) + arc.m_target.set_generating_conic(m_id); } - return (arc); + return arc; } - /*! - * Check whether the two arcs are equal (have the same graph). + /*! Check whether the two arcs are equal (have the same graph). * \param arc The compared arc. * \return (true) if the two arcs have the same graph; (false) otherwise. */ - bool equals (const Self& arc) const - { + bool equals(const Self& arc) const { // The two arc must have the same supporting conic curves. - if (! _has_same_supporting_conic (arc)) - return false; + if (! has_same_supporting_conic (arc)) return false; // Check that the arc endpoints are the same. Alg_kernel ker; - if (this->_orient == COLLINEAR) { - CGAL_assertion(arc._orient == COLLINEAR); - return((ker.equal_2_object()(this->_source, arc._source) && - ker.equal_2_object()(this->_target, arc._target)) || - (ker.equal_2_object()(this->_source, arc._target) && - ker.equal_2_object()(this->_target, arc._source))); + if (this->m_orient == COLLINEAR) { + CGAL_assertion(arc.m_orient == COLLINEAR); + return((ker.equal_2_object()(this->m_source, arc.m_source) && + ker.equal_2_object()(this->m_target, arc.m_target)) || + (ker.equal_2_object()(this->m_source, arc.m_target) && + ker.equal_2_object()(this->m_target, arc.m_source))); } - if (this->_orient == arc._orient) { + if (this->m_orient == arc.m_orient) { // Same orientation - the source and target points must be the same. - return (ker.equal_2_object()(this->_source, arc._source) && - ker.equal_2_object()(this->_target, arc._target)); + return (ker.equal_2_object()(this->m_source, arc.m_source) && + ker.equal_2_object()(this->m_target, arc.m_target)); } else { // Reverse orientation - the source and target points must be swapped. - return (ker.equal_2_object()(this->_source, arc._target) && - ker.equal_2_object()(this->_target, arc._source)); + return (ker.equal_2_object()(this->m_source, arc.m_target) && + ker.equal_2_object()(this->m_target, arc.m_source)); } } @@ -1052,16 +1009,14 @@ public: * \return (true) if it is possible to merge the two arcs; * (false) otherwise. */ - bool can_merge_with(const Self& arc) const - { + bool can_merge_with(const Self& arc) const { // In order to merge the two arcs, they should have the same supporting // conic. - if (! _has_same_supporting_conic(arc)) return false; + if (! has_same_supporting_conic(arc)) return false; // Check if the left endpoint of one curve is the right endpoint of the // other. - Alg_kernel ker; - + Alg_kernel ker; return (ker.equal_2_object() (right(), arc.left()) || ker.equal_2_object() (left(), arc.right())); } @@ -1070,40 +1025,31 @@ public: * \param arc The arc to merge with. * \pre The two arcs are mergeable. */ - void merge(const Self& arc) - { + void merge(const Self& arc) { CGAL_precondition (this->can_merge_with (arc)); // Check if we should extend the arc to the left or to the right. - Alg_kernel ker; + Alg_kernel ker; if (ker.equal_2_object() (right(), arc.left())) { // Extend the arc to the right. - if ((this->_info & IS_DIRECTED_RIGHT) != 0) this->_target = arc.right(); - else this->_source = arc.right(); + if ((this->m_info & IS_DIRECTED_RIGHT) != 0) this->m_target = arc.right(); + else this->m_source = arc.right(); } else { CGAL_precondition (ker.equal_2_object() (left(), arc.right())); // Extend the arc to the left. - if ((this->_info & IS_DIRECTED_RIGHT) != 0) - this->_source = arc.left(); + if ((this->m_info & IS_DIRECTED_RIGHT) != 0) + this->m_source = arc.left(); else - this->_target = arc.left(); + this->m_target = arc.left(); } - - return; } - bool is_upper() const - { - return ((this->_info & FACING_UP) != 0); - } + bool is_upper() const { return ((this->m_info & FACING_UP) != 0); } - bool is_lower() const - { - return ((this->_info & FACING_DOWN) != 0); - } + bool is_lower() const { return ((this->m_info & FACING_DOWN) != 0); } //@} private: @@ -1115,105 +1061,96 @@ private: * Set the properties of the x-monotone conic arc (for the usage of the * constructors). */ - void _set () - { + void set() { // Convert the coefficients of the supporting conic to algebraic numbers. - Nt_traits nt_traits; + Nt_traits nt_traits; - alg_r = nt_traits.convert (this->_r); - alg_s = nt_traits.convert (this->_s); - alg_t = nt_traits.convert (this->_t); - alg_u = nt_traits.convert (this->_u); - alg_v = nt_traits.convert (this->_v); - alg_w = nt_traits.convert (this->_w); + alg_r = nt_traits.convert(this->m_r); + alg_s = nt_traits.convert(this->m_s); + alg_t = nt_traits.convert(this->m_t); + alg_u = nt_traits.convert(this->m_u); + alg_v = nt_traits.convert(this->m_v); + alg_w = nt_traits.convert(this->m_w); // Set the generating conic ID for the source and target points. - this->_source.set_generating_conic (_id); - this->_target.set_generating_conic (_id); + this->m_source.set_generating_conic(m_id); + this->m_target.set_generating_conic(m_id); - // Clear the _info bits. - this->_info = Conic_arc_2::IS_VALID; + // Clear the m_info bits. + this->m_info = Conic_arc_2::IS_VALID; // Check if the arc is directed right (the target is lexicographically // greater than the source point), or to the left. - Alg_kernel ker; - Comparison_result dir_res = ker.compare_xy_2_object() (this->_source, - this->_target); + Alg_kernel ker; + Comparison_result dir_res = + ker.compare_xy_2_object()(this->m_source, this->m_target); CGAL_assertion (dir_res != EQUAL); - if (dir_res == SMALLER) - this->_info = (this->_info | IS_DIRECTED_RIGHT); + if (dir_res == SMALLER) this->m_info = (this->m_info | IS_DIRECTED_RIGHT); // Compute the degree of the underlying conic. - if (CGAL::sign (this->_r) != ZERO || - CGAL::sign (this->_s) != ZERO || - CGAL::sign (this->_t) != ZERO) + if ((CGAL::sign(this->m_r) != ZERO) || + (CGAL::sign(this->m_s) != ZERO) || + (CGAL::sign(this->m_t) != ZERO)) { - this->_info = (this->_info | DEGREE_2); + this->m_info = (this->m_info | DEGREE_2); - if (this->_orient == COLLINEAR) - { - this->_info = (this->_info | IS_SPECIAL_SEGMENT); + if (this->m_orient == COLLINEAR) { + this->m_info = (this->m_info | IS_SPECIAL_SEGMENT); - if (ker.compare_x_2_object() (this->_source, this->_target) == EQUAL) - { + if (ker.compare_x_2_object()(this->m_source, this->m_target) == EQUAL) { // The arc is a vertical segment: - this->_info = (this->_info | IS_VERTICAL_SEGMENT); + this->m_info = (this->m_info | IS_VERTICAL_SEGMENT); } return; } } - else - { - CGAL_assertion (CGAL::sign (this->_u) != ZERO || - CGAL::sign (this->_v) != ZERO); + else { + CGAL_assertion(CGAL::sign(this->m_u) != ZERO || + CGAL::sign(this->m_v) != ZERO); - if (CGAL::sign (this->_v) == ZERO) - { + if (CGAL::sign (this->m_v) == ZERO) { // The supporting curve is of the form: _u*x + _w = 0 - this->_info = (this->_info | IS_VERTICAL_SEGMENT); + this->m_info = (this->m_info | IS_VERTICAL_SEGMENT); } - this->_info = (this->_info | DEGREE_1); + this->m_info = (this->m_info | DEGREE_1); return; } - if (this->_orient == COLLINEAR) - return; + if (this->m_orient == COLLINEAR) return; // Compute a midpoint between the source and the target and get the y-value // of the arc at its x-coordiante. - Point_2 p_mid = ker.construct_midpoint_2_object() (this->_source, - this->_target); - Algebraic ys[2]; - CGAL_assertion_code(int n_ys = ) - _conic_get_y_coordinates (p_mid.x(), ys); + Point_2 p_mid = + ker.construct_midpoint_2_object()(this->m_source, this->m_target); + Algebraic ys[2]; + CGAL_assertion_code(int n_ys = ) + conic_get_y_coordinates(p_mid.x(), ys); - CGAL_assertion (n_ys != 0); + CGAL_assertion(n_ys != 0); // Check which solution lies on the x-monotone arc. - Point_2 p_arc_mid (p_mid.x(), ys[0]); + Point_2 p_arc_mid(p_mid.x(), ys[0]); - if (_is_strictly_between_endpoints (p_arc_mid)) - { + if (is_strictly_between_endpoints (p_arc_mid)) { // Mark that we should use the -sqrt(disc) root for points on this // x-monotone arc. - this->_info = (this->_info & ~PLUS_SQRT_DISC_ROOT); + this->m_info = (this->m_info & ~PLUS_SQRT_DISC_ROOT); } - else - { + else { CGAL_assertion (n_ys == 2); p_arc_mid = Point_2 (p_mid.x(), ys[1]); - CGAL_assertion (_is_strictly_between_endpoints (p_arc_mid)); + CGAL_assertion (is_strictly_between_endpoints (p_arc_mid)); // Mark that we should use the +sqrt(disc) root for points on this // x-monotone arc. - this->_info = (this->_info | PLUS_SQRT_DISC_ROOT); + this->m_info = (this->m_info | PLUS_SQRT_DISC_ROOT); } // Check whether the conic is facing up or facing down: @@ -1223,169 +1160,129 @@ private: // coordinate is (x1+x2)/2 and compare it to (y1+y2)/2. Comparison_result res = ker.compare_y_2_object() (p_arc_mid, p_mid); - if (res == LARGER) - { + if (res == LARGER) { // The arc is above the connecting segment, so it is facing upwards. - this->_info = (this->_info | FACING_UP); + this->m_info = (this->m_info | FACING_UP); } - else if (res == SMALLER) - { + else if (res == SMALLER) { // The arc is below the connecting segment, so it is facing downwards. - this->_info = (this->_info | FACING_DOWN); + this->m_info = (this->m_info | FACING_DOWN); } - - return; } - /*! - * Check if the arc is a special segment connecting two algebraic endpoints + /*! Check if the arc is a special segment connecting two algebraic endpoints * (and has no undelying integer conic coefficients). */ - bool _is_special_segment () const - { - return ((this->_info & IS_SPECIAL_SEGMENT) != 0); - } + bool is_special_segment() const + { return ((this->m_info & IS_SPECIAL_SEGMENT) != 0); } - /*! - * Check whether the given point lies on the supporting conic of the arc. + /*! Check whether the given point lies on the supporting conic of the arc. * \param px The x-coordinate of query point. * \param py The y-coordinate of query point. * \return (true) if p lies on the supporting conic; (false) otherwise. */ - bool _is_on_supporting_conic (const Algebraic& px, - const Algebraic& py) const - { - CGAL::Sign _sign; + bool is_on_supporting_conic(const Algebraic& px, const Algebraic& py) const { + CGAL::Sign _sign; - if (! _is_special_segment()) - { + if (! is_special_segment()) { // Check whether p satisfies the conic equation. // The point must satisfy: r*x^2 + s*y^2 + t*xy + u*x + v*y + w = 0. - _sign = CGAL::sign ((alg_r*px + alg_t*py + alg_u) * px + - (alg_s*py + alg_v) * py + - alg_w); + _sign = CGAL::sign((alg_r*px + alg_t*py + alg_u) * px + + (alg_s*py + alg_v) * py + alg_w); } - else - { + else { // Check whether p satisfies the equation of the line stored with the // extra data. - _sign = _sign_of_extra_data (px, py); + _sign = sign_of_extra_data(px, py); } return (_sign == ZERO); } - /*! - * Check whether the two arcs have the same supporting conic. + /*! Check whether the two arcs have the same supporting conic. * \param arc The compared arc. * \return (true) if the two supporting conics are the same. */ - bool _has_same_supporting_conic (const Self& arc) const - { + bool has_same_supporting_conic(const Self& arc) const { // Check if the two arcs originate from the same conic: - if (_id == arc._id && _id.is_valid() && arc._id.is_valid()) - return (true); + if (m_id == arc.m_id && m_id.is_valid() && arc.m_id.is_valid()) return true; // In case both arcs are collinear, check if they have the same // supporting lines. - if (this->_orient == COLLINEAR && arc._orient == COLLINEAR) - { + if ((this->m_orient == COLLINEAR) && (arc.m_orient == COLLINEAR)) { // Construct the two supporting lines and compare them. - Alg_kernel ker; - typename Alg_kernel::Construct_line_2 construct_line = - ker.construct_line_2_object(); - typename Alg_kernel::Line_2 l1 = construct_line (this->_source, - this->_target); - typename Alg_kernel::Line_2 l2 = construct_line (arc._source, - arc._target); - typename Alg_kernel::Equal_2 equal = ker.equal_2_object(); + Alg_kernel ker; + auto construct_line = ker.construct_line_2_object(); + typename Alg_kernel::Line_2 l1 = + construct_line(this->m_source, this->m_target); + typename Alg_kernel::Line_2 l2 = + construct_line(arc.m_source, arc.m_target); + auto equal = ker.equal_2_object(); - if (equal (l1, l2)) - return (true); + if (equal(l1, l2)) return true; // Try to compare l1 with the opposite of l2. - l2 = construct_line (arc._target, arc._source); + l2 = construct_line(arc.m_target, arc.m_source); - return (equal (l1, l2)); + return equal(l1, l2); } - else if (this->_orient == COLLINEAR || arc._orient == COLLINEAR) - { + else if ((this->m_orient == COLLINEAR) || (arc.m_orient == COLLINEAR)) { // Only one arc is collinear, so the supporting curves cannot be the // same: - return (false); + return false; } // Check whether the coefficients of the two supporting conics are equal // up to a constant factor. - Integer factor1 = 1; - Integer factor2 = 1; + Integer factor1 = 1; + Integer factor2 = 1; - if (CGAL::sign (this->_r) != ZERO) - factor1 = this->_r; - else if (CGAL::sign (this->_s) != ZERO) - factor1 = this->_s; - else if (CGAL::sign (this->_t) != ZERO) - factor1 = this->_t; - else if (CGAL::sign (this->_u) != ZERO) - factor1 = this->_u; - else if (CGAL::sign (this->_v) != ZERO) - factor1 = this->_v; - else if (CGAL::sign (this->_w) != ZERO) - factor1 = this->_w; + if (CGAL::sign(this->m_r) != ZERO) factor1 = this->m_r; + else if (CGAL::sign(this->m_s) != ZERO) factor1 = this->m_s; + else if (CGAL::sign(this->m_t) != ZERO) factor1 = this->m_t; + else if (CGAL::sign(this->m_u) != ZERO) factor1 = this->m_u; + else if (CGAL::sign(this->m_v) != ZERO) factor1 = this->m_v; + else if (CGAL::sign(this->m_w) != ZERO) factor1 = this->m_w; - if (CGAL::sign (arc._r) != ZERO) - factor2 = arc._r; - else if (CGAL::sign (arc._s) != ZERO) - factor2 = arc._s; - else if (CGAL::sign (arc._t) != ZERO) - factor2 = arc._t; - else if (CGAL::sign (arc._u) != ZERO) + if (CGAL::sign(arc.m_r) != ZERO) factor2 = arc.m_r; + else if (CGAL::sign(arc.m_s) != ZERO) factor2 = arc.m_s; + else if (CGAL::sign(arc.m_t) != ZERO) factor2 = arc.m_t; + else if (CGAL::sign(arc.m_u) != ZERO) factor2 = arc.m_u; + else if (CGAL::sign(arc.m_v) != ZERO) factor2 = arc.m_v; + else if (CGAL::sign(arc.m_w) != ZERO) factor2 = arc.m_w; - factor2 = arc._u; - else if (CGAL::sign (arc._v) != ZERO) - factor2 = arc._v; - else if (CGAL::sign (arc._w) != ZERO) - factor2 = arc._w; - - return (CGAL::compare (this->_r * factor2, arc._r * factor1) == EQUAL && - CGAL::compare (this->_s * factor2, arc._s * factor1) == EQUAL && - CGAL::compare (this->_t * factor2, arc._t * factor1) == EQUAL && - CGAL::compare (this->_u * factor2, arc._u * factor1) == EQUAL && - CGAL::compare (this->_v * factor2, arc._v * factor1) == EQUAL && - CGAL::compare (this->_w * factor2, arc._w * factor1) == EQUAL); + return (CGAL::compare(this->m_r * factor2, arc.m_r * factor1) == EQUAL && + CGAL::compare(this->m_s * factor2, arc.m_s * factor1) == EQUAL && + CGAL::compare(this->m_t * factor2, arc.m_t * factor1) == EQUAL && + CGAL::compare(this->m_u * factor2, arc.m_u * factor1) == EQUAL && + CGAL::compare(this->m_v * factor2, arc.m_v * factor1) == EQUAL && + CGAL::compare(this->m_w * factor2, arc.m_w * factor1) == EQUAL); } - /*! - * Get the i'th order derivative by x of the conic at the point p=(x,y). + /*! Get the i'th order derivative by x of the conic at the point p=(x,y). * \param p The point where we derive. * \param i The order of the derivatives (either 1, 2 or 3). * \param slope_numer The numerator of the slope. * \param slope_denom The denominator of the slope. * \todo Allow higher order derivatives. */ - void _derive_by_x_at (const Point_2& p, const unsigned int& i, - Algebraic& slope_numer, Algebraic& slope_denom) const - { - if (_is_special_segment()) - { + void derive_by_x_at(const Point_2& p, const unsigned int& i, + Algebraic& slope_numer, Algebraic& slope_denom) const { + if (is_special_segment()) { // Special treatment for special segments, given by (a*x + b*y + c = 0), // so their first-order derivative by x is simply -a/b. The higher-order // derivatives are all 0. - if (i == 1) - { - if (CGAL::sign (this->_extra_data_P->b) != NEGATIVE) - { - slope_numer = - this->_extra_data_P->a; - slope_denom = this->_extra_data_P->b; + if (i == 1) { + if (CGAL::sign (this->m_extra_data->b) != NEGATIVE) { + slope_numer = - this->m_extra_data->a; + slope_denom = this->m_extra_data->b; } - else - { - slope_numer = this->_extra_data_P->a; - slope_denom = - this->_extra_data_P->b; + else { + slope_numer = this->m_extra_data->a; + slope_denom = - this->m_extra_data->b; } } - else - { + else { slope_numer = 0; slope_denom = 1; } @@ -1401,20 +1298,17 @@ private: // y' = - ---------------- = - ------- // 2s*y + t*x + v beta // - const Algebraic _two = 2; - const Algebraic sl_numer = _two*alg_r*p.x() + alg_t*p.y() + alg_u; - const Algebraic sl_denom = _two*alg_s*p.y() + alg_t*p.x() + alg_v; + const Algebraic two = 2; + const Algebraic sl_numer = two*alg_r*p.x() + alg_t*p.y() + alg_u; + const Algebraic sl_denom = two*alg_s*p.y() + alg_t*p.x() + alg_v; - if (i == 1) - { + if (i == 1) { // Make sure that the denominator is always positive. - if (CGAL::sign (sl_denom) != NEGATIVE) - { + if (CGAL::sign (sl_denom) != NEGATIVE) { slope_numer = -sl_numer; slope_denom = sl_denom; } - else - { + else { slope_numer = sl_numer; slope_denom = -sl_denom; } @@ -1428,22 +1322,18 @@ private: // y'' = -2 ------------------------------------- = ------- // beta^3 delta // - const Algebraic sl2_numer = alg_s * sl_numer*sl_numer - - alg_t * sl_numer*sl_denom + - alg_r * sl_denom*sl_denom; - const Algebraic sl2_denom = sl_denom*sl_denom*sl_denom; + const Algebraic sl2_numer = alg_s * sl_numer*sl_numer - + alg_t * sl_numer*sl_denom + alg_r * sl_denom*sl_denom; + const Algebraic sl2_denom = sl_denom*sl_denom*sl_denom; - if (i == 2) - { + if (i == 2) { // Make sure that the denominator is always positive. - if (CGAL::sign (sl_denom) != NEGATIVE) - { - slope_numer = -_two *sl2_numer; + if (CGAL::sign (sl_denom) != NEGATIVE) { + slope_numer = -two *sl2_numer; slope_denom = sl2_denom; } - else - { - slope_numer = _two *sl2_numer; + else { + slope_numer = two *sl2_numer; slope_denom = -sl2_denom; } @@ -1456,20 +1346,17 @@ private: // y''' = -6 ------------------------------ // beta^2 * delta // - const Algebraic sl3_numer = (_two * alg_s * sl_numer - - alg_t * sl_denom) * sl2_numer; - const Algebraic sl3_denom = sl_denom*sl_denom * sl2_denom; + const Algebraic sl3_numer = + (two * alg_s * sl_numer - alg_t * sl_denom) * sl2_numer; + const Algebraic sl3_denom = sl_denom*sl_denom * sl2_denom; - if (i == 3) - { + if (i == 3) { // Make sure that the denominator is always positive. - if (CGAL::sign (sl_denom) != NEGATIVE) - { + if (CGAL::sign (sl_denom) != NEGATIVE) { slope_numer = -6 * sl3_numer; slope_denom = sl3_denom; } - else - { + else { slope_numer = 6 * sl3_numer; slope_denom = -sl2_denom; } @@ -1479,7 +1366,6 @@ private: // \todo Handle higher-order derivatives as well. CGAL_error(); - return; } /*! @@ -1490,29 +1376,23 @@ private: * \param slope_denom The denominator of the slope. * \todo Allow higher order derivatives. */ - void _derive_by_y_at (const Point_2& p, const int& i, - Algebraic& slope_numer, Algebraic& slope_denom) const - { - if (_is_special_segment()) - { + void derive_by_y_at(const Point_2& p, const int& i, + Algebraic& slope_numer, Algebraic& slope_denom) const { + if (is_special_segment()) { // Special treatment for special segments, given by (a*x + b*y + c = 0), // so their first-order derivative by x is simply -b/a. The higher-order // derivatives are all 0. - if (i == 1) - { - if (CGAL::sign (this->_extra_data_P->a) != NEGATIVE) - { - slope_numer = - this->_extra_data_P->b; - slope_denom = this->_extra_data_P->a; + if (i == 1) { + if (CGAL::sign (this->m_extra_data->a) != NEGATIVE) { + slope_numer = - this->m_extra_data->b; + slope_denom = this->m_extra_data->a; } - else - { - slope_numer = this->_extra_data_P->b; - slope_denom = - this->_extra_data_P->a; + else { + slope_numer = this->m_extra_data->b; + slope_denom = - this->m_extra_data->a; } } - else - { + else { slope_numer = 0; slope_denom = 1; } @@ -1528,25 +1408,21 @@ private: // x' = - ---------------- = ------- // 2r*x + t*y + u beta // - const Algebraic _two = 2; - const Algebraic sl_numer = _two*alg_s*p.y() + alg_t*p.x() + alg_v; - const Algebraic sl_denom = _two*alg_r*p.x() + alg_t*p.y() + alg_u; + const Algebraic two = 2; + const Algebraic sl_numer = two*alg_s*p.y() + alg_t*p.x() + alg_v; + const Algebraic sl_denom = two*alg_r*p.x() + alg_t*p.y() + alg_u; - if (i == 1) - { + if (i == 1) { // Make sure that the denominator is always positive. - if (CGAL::sign (sl_denom) != NEGATIVE) - { + if (CGAL::sign (sl_denom) != NEGATIVE) { slope_numer = -sl_numer; slope_denom = sl_denom; } - else - { + else { slope_numer = sl_numer; slope_denom = -sl_denom; } - return; } @@ -1556,23 +1432,18 @@ private: // x'' = -2 ------------------------------------- // beta^3 // - const Algebraic sl2_numer = alg_r * sl_numer*sl_numer - - alg_t * sl_numer*sl_denom + - alg_s * sl_denom*sl_denom; - const Algebraic sl2_denom = sl_denom*sl_denom*sl_denom; - - if (i == 2) - { + const Algebraic sl2_numer = alg_r * sl_numer*sl_numer - + alg_t * sl_numer*sl_denom + alg_s * sl_denom*sl_denom; + const Algebraic sl2_denom = sl_denom*sl_denom*sl_denom; + if (i == 2) { // Make sure that the denominator is always positive. - if (CGAL::sign (sl_denom) != NEGATIVE) - { - slope_numer = -_two *sl2_numer; + if (CGAL::sign (sl_denom) != NEGATIVE) { + slope_numer = -two *sl2_numer; slope_denom = sl2_denom; } - else - { - slope_numer = _two *sl2_numer; + else { + slope_numer = two *sl2_numer; slope_denom = -sl2_denom; } @@ -1585,20 +1456,17 @@ private: // y''' = -6 ------------------------------ // beta^2 * delta // - const Algebraic sl3_numer = (_two * alg_r * sl_numer - - alg_t * sl_denom) * sl2_numer; - const Algebraic sl3_denom = sl_denom*sl_denom * sl2_denom; + const Algebraic sl3_numer = + (two * alg_r * sl_numer - alg_t * sl_denom) * sl2_numer; + const Algebraic sl3_denom = sl_denom*sl_denom * sl2_denom; - if (i == 3) - { + if (i == 3) { // Make sure that the denominator is always positive. - if (CGAL::sign (sl_denom) != NEGATIVE) - { + if (CGAL::sign (sl_denom) != NEGATIVE) { slope_numer = -6 * sl3_numer; slope_denom = sl3_denom; } - else - { + else { slope_numer = 6 * sl3_numer; slope_denom = -sl2_denom; } @@ -1608,161 +1476,151 @@ private: // \todo Handle higher-order derivatives as well. CGAL_error(); - return; } - /*! - * Compute the overlap with a given arc, which is supposed to have the same + /*! Compute the overlap with a given arc, which is supposed to have the same * supporting conic curve as this arc. * \param arc The given arc. * \param overlap Output: The overlapping arc (if any). * \return Whether we found an overlap. */ - bool _compute_overlap (const Self& arc, Self& overlap) const - { + bool compute_overlap(const Self& arc, Self& overlap) const { // Check if the two arcs are identical. - if (equals (arc)) - { + if (equals(arc)) { overlap = arc; - return (true); + return true; } - if (_is_strictly_between_endpoints (arc.left())) - { - if (_is_strictly_between_endpoints(arc.right())) - { + if (is_strictly_between_endpoints (arc.left())) { + if (is_strictly_between_endpoints(arc.right())) { // Case 1 - *this: +-----------> // arc: +=====> overlap = arc; - return (true); + return true; } - else - { + else { // Case 2 - *this: +-----------> // arc: +=====> overlap = *this; - if ((overlap._info & IS_DIRECTED_RIGHT) != 0) - overlap._source = arc.left(); + if ((overlap.m_info & IS_DIRECTED_RIGHT) != 0) + overlap.m_source = arc.left(); else - overlap._target = arc.left(); + overlap.m_target = arc.left(); - return (true); + return true; } } - else if (_is_strictly_between_endpoints (arc.right())) - { + else if (is_strictly_between_endpoints(arc.right())) { // Case 3 - *this: +-----------> // arc: +=====> overlap = *this; - if ((overlap._info & IS_DIRECTED_RIGHT) != 0) - overlap._target = arc.right(); + if ((overlap.m_info & IS_DIRECTED_RIGHT) != 0) + overlap.m_target = arc.right(); else - overlap._source = arc.right(); + overlap.m_source = arc.right(); - return (true); + return true; } - else if (arc._is_between_endpoints (this->_source) && - arc._is_between_endpoints (this->_target) && - (arc._is_strictly_between_endpoints(this->_source) || - arc._is_strictly_between_endpoints(this->_target))) + else if (arc.is_between_endpoints(this->m_source) && + arc.is_between_endpoints(this->m_target) && + (arc.is_strictly_between_endpoints(this->m_source) || + arc.is_strictly_between_endpoints(this->m_target))) { // Case 4 - *this: +-----------> // arc: +================> overlap = *this; - return (true); + return true; } // If we reached here, there are no overlaps: - return (false); + return false; } - /*! - * Intersect the supporing conic curves of this arc and the given arc. + /*! Intersect the supporing conic curves of this arc and the given arc. * \param arc The arc to intersect with. * \param inter_list The list of intersection points. */ - void _intersect_supporting_conics(const Self& arc, - Intersection_list& inter_list) const - { - if (_is_special_segment() && ! arc._is_special_segment()) { + void intersect_supporting_conics(const Self& arc, + Intersection_list& inter_list) const { + if (is_special_segment() && ! arc.is_special_segment()) { // If one of the arcs is a special segment, make sure it is (arc). - arc._intersect_supporting_conics(*this, inter_list); + arc.intersect_supporting_conics(*this, inter_list); return; } - const int deg1 = ((this->_info & DEGREE_MASK) == DEGREE_1) ? 1 : 2; - const int deg2 = ((arc._info & DEGREE_MASK) == DEGREE_1) ? 1 : 2; + const int deg1 = ((this->m_info & DEGREE_MASK) == DEGREE_1) ? 1 : 2; + const int deg2 = ((arc.m_info & DEGREE_MASK) == DEGREE_1) ? 1 : 2; Nt_traits nt_traits; Algebraic xs[4]; int n_xs = 0; Algebraic ys[4]; int n_ys = 0; - if (arc._is_special_segment()) { + if (arc.is_special_segment()) { // The second arc is a special segment (a*x + b*y + c = 0). - if (_is_special_segment()) { + if (is_special_segment()) { // Both arc are sepcial segment, so they have at most one intersection // point. - Algebraic denom = this->_extra_data_P->a * arc._extra_data_P->b - - this->_extra_data_P->b * arc._extra_data_P->a; + Algebraic denom = this->m_extra_data->a * arc.m_extra_data->b - + this->m_extra_data->b * arc.m_extra_data->a; if (CGAL::sign (denom) != CGAL::ZERO) { - xs[0] = (this->_extra_data_P->b * arc._extra_data_P->c - - this->_extra_data_P->c * arc._extra_data_P->b) / denom; + xs[0] = (this->m_extra_data->b * arc.m_extra_data->c - + this->m_extra_data->c * arc.m_extra_data->b) / denom; n_xs = 1; - ys[0] = (this->_extra_data_P->c * arc._extra_data_P->a - - this->_extra_data_P->a * arc._extra_data_P->c) / denom; + ys[0] = (this->m_extra_data->c * arc.m_extra_data->a - + this->m_extra_data->a * arc.m_extra_data->c) / denom; n_ys = 1; } } else { // Compute the x-coordinates of the intersection points. - n_xs = _compute_resultant_roots (nt_traits, - alg_r, alg_s, alg_t, - alg_u, alg_v, alg_w, - deg1, - arc._extra_data_P->a, - arc._extra_data_P->b, - arc._extra_data_P->c, - xs); + n_xs = compute_resultant_roots(nt_traits, + alg_r, alg_s, alg_t, + alg_u, alg_v, alg_w, + deg1, + arc.m_extra_data->a, + arc.m_extra_data->b, + arc.m_extra_data->c, + xs); CGAL_assertion (n_xs <= 2); // Compute the y-coordinates of the intersection points. - n_ys = _compute_resultant_roots (nt_traits, - alg_s, alg_r, alg_t, - alg_v, alg_u, alg_w, - deg1, - arc._extra_data_P->b, - arc._extra_data_P->a, - arc._extra_data_P->c, - ys); - CGAL_assertion (n_ys <= 2); + n_ys = compute_resultant_roots(nt_traits, + alg_s, alg_r, alg_t, + alg_v, alg_u, alg_w, + deg1, + arc.m_extra_data->b, + arc.m_extra_data->a, + arc.m_extra_data->c, + ys); + CGAL_assertion(n_ys <= 2); } } else { // Compute the x-coordinates of the intersection points. - n_xs = _compute_resultant_roots (nt_traits, - this->_r, this->_s, this->_t, - this->_u, this->_v, this->_w, - deg1, - arc._r, arc._s, arc._t, - arc._u, arc._v, arc._w, - deg2, - xs); - CGAL_assertion (n_xs <= 4); + n_xs = compute_resultant_roots(nt_traits, + this->m_r, this->m_s, this->m_t, + this->m_u, this->m_v, this->m_w, + deg1, + arc.m_r, arc.m_s, arc.m_t, + arc.m_u, arc.m_v, arc.m_w, + deg2, + xs); + CGAL_assertion(n_xs <= 4); // Compute the y-coordinates of the intersection points. - n_ys = _compute_resultant_roots (nt_traits, - this->_s, this->_r, this->_t, - this->_v, this->_u, this->_w, - deg1, - arc._s, arc._r, arc._t, - arc._v, arc._u, arc._w, - deg2, - ys); + n_ys = compute_resultant_roots(nt_traits, + this->m_s, this->m_r, this->m_t, + this->m_v, this->m_u, this->m_w, + deg1, + arc.m_s, arc.m_r, arc.m_t, + arc.m_v, arc.m_u, arc.m_w, + deg2, + ys); CGAL_assertion(n_ys <= 4); } @@ -1770,84 +1628,77 @@ private: // x and y-coordinates are sorted in ascending order, we output the // intersection points in lexicographically ascending order. unsigned int mult; - int i, j; + int i, j; - if (arc._is_special_segment()) - { - if (n_xs == 0 || n_ys == 0) - return; + if (arc.is_special_segment()) { + if ((n_xs == 0) || (n_ys == 0)) return; - if (n_xs == 1 && n_ys == 1) - { + if ((n_xs == 1) && (n_ys == 1)) { // Single intersection. Conic_point_2 ip (xs[0], ys[0]); - ip.set_generating_conic (_id); - ip.set_generating_conic (arc._id); + ip.set_generating_conic(m_id); + ip.set_generating_conic (arc.m_id); // In case the other curve is of degree 2, this is a tangency point. - mult = (deg1 == 1 || _is_special_segment()) ? 1 : 2; - inter_list.push_back(Intersection_point (ip, mult)); + mult = ((deg1 == 1) || is_special_segment()) ? 1 : 2; + inter_list.push_back(Intersection_point(ip, mult)); } - else if (n_xs == 1 && n_ys == 2) - { - Conic_point_2 ip1 (xs[0], ys[0]); + else if ((n_xs == 1) && (n_ys == 2)) { + Conic_point_2 ip1(xs[0], ys[0]); - ip1.set_generating_conic (_id); - ip1.set_generating_conic (arc._id); + ip1.set_generating_conic(m_id); + ip1.set_generating_conic(arc.m_id); - inter_list.push_back(Intersection_point (ip1, 1)); + inter_list.push_back(Intersection_point(ip1, 1)); - Conic_point_2 ip2 (xs[0], ys[1]); + Conic_point_2 ip2 (xs[0], ys[1]); - ip2.set_generating_conic (_id); - ip2.set_generating_conic (arc._id); + ip2.set_generating_conic(m_id); + ip2.set_generating_conic(arc.m_id); - inter_list.push_back(Intersection_point (ip2, 1)); + inter_list.push_back(Intersection_point(ip2, 1)); } - else if (n_xs == 2 && n_ys == 1) - { - Conic_point_2 ip1 (xs[0], ys[0]); + else if ((n_xs == 2) && (n_ys == 1)) { + Conic_point_2 ip1 (xs[0], ys[0]); - ip1.set_generating_conic (_id); - ip1.set_generating_conic (arc._id); + ip1.set_generating_conic(m_id); + ip1.set_generating_conic (arc.m_id); - inter_list.push_back(Intersection_point (ip1, 1)); + inter_list.push_back(Intersection_point(ip1, 1)); - Conic_point_2 ip2 (xs[1], ys[0]); + Conic_point_2 ip2 (xs[1], ys[0]); - ip2.set_generating_conic (_id); - ip2.set_generating_conic (arc._id); + ip2.set_generating_conic(m_id); + ip2.set_generating_conic(arc.m_id); - inter_list.push_back(Intersection_point (ip2, 1)); + inter_list.push_back(Intersection_point(ip2, 1)); } else { - CGAL_assertion (n_xs == 2 && n_ys == 2); + CGAL_assertion((n_xs == 2) && (n_ys == 2)); // The x-coordinates and the y-coordinates are given in ascending // order. If the slope of the segment is positive, we pair the // coordinates as is - otherwise, we swap the pairs. int ind_first_y = 0, ind_second_y = 1; - if (CGAL::sign (arc._extra_data_P->b) == - CGAL::sign(arc._extra_data_P->a)) - { + if (CGAL::sign(arc.m_extra_data->b) == CGAL::sign(arc.m_extra_data->a)) { ind_first_y = 1; ind_second_y = 0; } Conic_point_2 ip1(xs[0], ys[ind_first_y]); - ip1.set_generating_conic(_id); - ip1.set_generating_conic(arc._id); + ip1.set_generating_conic(m_id); + ip1.set_generating_conic(arc.m_id); - inter_list.push_back(Intersection_point (ip1, 1)); + inter_list.push_back(Intersection_point(ip1, 1)); Conic_point_2 ip2(xs[1], ys[ind_second_y]); - ip2.set_generating_conic (_id); - ip2.set_generating_conic (arc._id); + ip2.set_generating_conic(m_id); + ip2.set_generating_conic(arc.m_id); inter_list.push_back(Intersection_point(ip2, 1)); } @@ -1855,81 +1706,74 @@ private: return; } - for (i = 0; i < n_xs; i++) { - for (j = 0; j < n_ys; j++) { - if (_is_on_supporting_conic (xs[i], ys[j]) && - arc._is_on_supporting_conic (xs[i], ys[j])) + for (i = 0; i < n_xs; ++i) { + for (j = 0; j < n_ys; ++j) { + if (is_on_supporting_conic (xs[i], ys[j]) && + arc.is_on_supporting_conic(xs[i], ys[j])) { // Create the intersection point and set its generating conics. Conic_point_2 ip(xs[i], ys[j]); - ip.set_generating_conic (_id); - ip.set_generating_conic (arc._id); + ip.set_generating_conic(m_id); + ip.set_generating_conic(arc.m_id); // Compute the multiplicity of the intersection point. if (deg1 == 1 && deg2 == 1) mult = 1; - else mult = _multiplicity_of_intersection_point(arc, ip); + else mult = multiplicity_of_intersection_point(arc, ip); // Insert the intersection point to the output list. inter_list.push_back(Intersection_point(ip, mult)); } } } - - return; } - /*! - * Compute the multiplicity of an intersection point. + /*! Compute the multiplicity of an intersection point. * \param arc The arc to intersect with. * \param p The intersection point. * \return The multiplicity of the intersection point. */ - unsigned int _multiplicity_of_intersection_point (const Self& arc, - const Point_2& p) const - { - CGAL_assertion (! _is_special_segment() || ! arc._is_special_segment()); + unsigned int multiplicity_of_intersection_point(const Self& arc, + const Point_2& p) const { + CGAL_assertion(! is_special_segment() || ! arc.is_special_segment()); // Compare the slopes of the two arcs at p, using their first-order // partial derivatives. - Algebraic slope1_numer, slope1_denom; - Algebraic slope2_numer, slope2_denom; + Algebraic slope1_numer, slope1_denom; + Algebraic slope2_numer, slope2_denom; - _derive_by_x_at (p, 1, slope1_numer, slope1_denom); - arc._derive_by_x_at (p, 1, slope2_numer, slope2_denom); + derive_by_x_at(p, 1, slope1_numer, slope1_denom); + arc.derive_by_x_at(p, 1, slope2_numer, slope2_denom); - if (CGAL::compare (slope1_numer*slope2_denom, - slope2_numer*slope1_denom) != EQUAL) - { + if (CGAL::compare(slope1_numer*slope2_denom, slope2_numer*slope1_denom) != + EQUAL) { // Different slopes at p - the mutiplicity of p is 1: - return (1); + return 1; } - if (CGAL::sign (slope1_denom) != ZERO && - CGAL::sign (slope2_denom) != ZERO) - { + if (CGAL::sign(slope1_denom) != ZERO && + CGAL::sign(slope2_denom) != ZERO) { // The curves do not have a vertical slope at p. // Compare their second-order derivative by x: - _derive_by_x_at (p, 2, slope1_numer, slope1_denom); - arc._derive_by_x_at (p, 2, slope2_numer, slope2_denom); + derive_by_x_at(p, 2, slope1_numer, slope1_denom); + arc.derive_by_x_at(p, 2, slope2_numer, slope2_denom); } - else - { + else { // Both curves have a vertical slope at p. // Compare their second-order derivative by y: - _derive_by_y_at (p, 2, slope1_numer, slope1_denom); - arc._derive_by_y_at (p, 2, slope2_numer, slope2_denom); + derive_by_y_at(p, 2, slope1_numer, slope1_denom); + arc.derive_by_y_at(p, 2, slope2_numer, slope2_denom); } - if (CGAL::compare (slope1_numer*slope2_denom, - slope2_numer*slope1_denom) != EQUAL) + if (CGAL::compare(slope1_numer*slope2_denom, + slope2_numer*slope1_denom) != EQUAL) { // Different curvatures at p - the mutiplicity of p is 2: - return (2); + return 2; } // If we reached here, the multiplicity of the intersection point is 3: - return (3); + return 3; } //@} @@ -1939,8 +1783,8 @@ private: * Exporter for x-monotone conic arcs. */ template -std::ostream& operator<< (std::ostream& os, - const _Conic_x_monotone_arc_2& arc) +std::ostream& operator<<(std::ostream& os, + const _Conic_x_monotone_arc_2& arc) { // Output the supporting conic curve. os << "{" << CGAL::to_double(arc.r()) << "*x^2 + " @@ -1954,12 +1798,9 @@ std::ostream& operator<< (std::ostream& os, os << " : (" << CGAL::to_double(arc.source().x()) << "," << CGAL::to_double(arc.source().y()) << ") "; - if (arc.orientation() == CLOCKWISE) - os << "--cw-->"; - else if (arc.orientation() == COUNTERCLOCKWISE) - os << "--ccw-->"; - else - os << "--l-->"; + if (arc.orientation() == CLOCKWISE) os << "--cw-->"; + else if (arc.orientation() == COUNTERCLOCKWISE) os << "--ccw-->"; + else os << "--l-->"; os << " (" << CGAL::to_double(arc.target().x()) << "," << CGAL::to_double(arc.target().y()) << ")";