Aos 2 fixes efif (#9133)

## Summary of Changes

This addresses issue #9084. In particular, I replaced `Cartesian` with
`Simple_cartesian` in all traits.
I also defined Multiplicity to be `std::size_t` in all traits. In
addition, I replaced `typedef` with `using` and properly indented and
cleaned up the code in the source files I touched. I simplified the code
that approximates a point of the traits classes `Arr_linear_traits_2`,
`Arr_segment_traits_2`, and `Arr_non_caching_segment_basic_traits_2.h`.
I did not use the
[GAL::Cartesian_coverter](https://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Cartesian__converter.html)
(mentioned in issue #9084) because the code is now simple as it is(just
one line in each traits class).

I also added a missing `inline` in draw_arrangement_2. This is unrelated
to the above.

## Release Management

* Affected package(s): Arrangement_on_surface_2
* Issue(s) solved (if any): fix #9084
* Feature/Small Feature (if any):
* Link to compiled documentation (obligatory for small feature) [*wrong
link name to be changed*](httpssss://wrong_URL_to_be_changed/Manual/Pkg)
* License and copyright ownership: TAU
This commit is contained in:
Sebastien Loriot 2025-12-03 11:45:33 +01:00 committed by GitHub
commit 18ee149f2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 3003 additions and 3842 deletions

View File

@ -30,7 +30,7 @@
#include <CGAL/tags.h> #include <CGAL/tags.h>
#include <CGAL/Arr_tags.h> #include <CGAL/Arr_tags.h>
#include <CGAL/Cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/Arr_geometry_traits/Circle_segment_2.h> #include <CGAL/Arr_geometry_traits/Circle_segment_2.h>
namespace CGAL { namespace CGAL {
@ -41,31 +41,31 @@ namespace CGAL {
template <typename Kernel_, bool Filter = true> template <typename Kernel_, bool Filter = true>
class Arr_circle_segment_traits_2 { class Arr_circle_segment_traits_2 {
public: public:
typedef Kernel_ Kernel; using Kernel = Kernel_;
typedef typename Kernel::FT NT; using NT = typename Kernel::FT;
typedef typename Kernel::Point_2 Rational_point_2; using Rational_point_2 = typename Kernel::Point_2;
typedef typename Kernel::Segment_2 Rational_segment_2; using Rational_segment_2 = typename Kernel::Segment_2;
typedef typename Kernel::Circle_2 Rational_circle_2; using Rational_circle_2 = typename Kernel::Circle_2;
typedef _One_root_point_2<NT, Filter> Point_2; using Point_2 = _One_root_point_2<NT, Filter>;
typedef typename Point_2::CoordNT CoordNT; using CoordNT = typename Point_2::CoordNT;
typedef _Circle_segment_2<Kernel, Filter> Curve_2; using Curve_2 = _Circle_segment_2<Kernel, Filter>;
typedef _X_monotone_circle_segment_2<Kernel, Filter> X_monotone_curve_2; using X_monotone_curve_2 = _X_monotone_circle_segment_2<Kernel, Filter>;
typedef unsigned int Multiplicity; using Multiplicity = std::size_t;
typedef Arr_circle_segment_traits_2<Kernel, Filter> Self; using Self = Arr_circle_segment_traits_2<Kernel, Filter>;
// Category tags: // Category tags:
typedef Tag_true Has_left_category; using Has_left_category = Tag_true;
typedef Tag_true Has_merge_category; using Has_merge_category = Tag_true;
typedef Tag_false Has_do_intersect_category; using Has_do_intersect_category = Tag_false;
typedef Arr_oblivious_side_tag Left_side_category; using Left_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Bottom_side_category; using Bottom_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Top_side_category; using Top_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Right_side_category; using Right_side_category = Arr_oblivious_side_tag;
protected: protected:
// Type definition for the intersection points mapping. // Type definition for the intersection points mapping.
typedef typename X_monotone_curve_2::Intersection_map Intersection_map; using Intersection_map = typename X_monotone_curve_2::Intersection_map;
mutable Intersection_map inter_map; // Mapping pairs of curve IDs to their mutable Intersection_map inter_map; // Mapping pairs of curve IDs to their
// intersection points. // intersection points.
@ -78,8 +78,7 @@ public:
{} {}
/*! obtains the next curve index. */ /*! obtains the next curve index. */
static unsigned int get_index () static unsigned int get_index() {
{
#ifdef CGAL_NO_ATOMIC #ifdef CGAL_NO_ATOMIC
static unsigned int index; static unsigned int index;
#else #else
@ -91,8 +90,7 @@ public:
/// \name Basic functor definitions. /// \name Basic functor definitions.
//@{ //@{
class Compare_x_2 class Compare_x_2 {
{
public: public:
/*! compares the \f$x\f$-coordinates of two points. /*! compares the \f$x\f$-coordinates of two points.
* \param p1 The first point. * \param p1 The first point.
@ -101,23 +99,17 @@ public:
* SMALLER if x(p1) < x(p2); * SMALLER if x(p1) < x(p2);
* EQUAL if x(p1) = x(p2). * EQUAL if x(p1) = x(p2).
*/ */
Comparison_result operator() (const Point_2& p1, const Point_2& p2) const Comparison_result operator() (const Point_2& p1, const Point_2& p2) const {
{ if (p1.identical (p2)) return (EQUAL);
if (p1.identical (p2))
return (EQUAL);
return (CGAL::compare (p1.x(), p2.x())); return (CGAL::compare (p1.x(), p2.x()));
} }
}; };
/*! obtains a `Compare_x_2` functor object. */ /*! obtains a `Compare_x_2` functor object. */
Compare_x_2 compare_x_2_object () const Compare_x_2 compare_x_2_object () const { return Compare_x_2(); }
{
return Compare_x_2();
}
class Compare_xy_2 class Compare_xy_2 {
{
public: public:
/*! compares two points lexigoraphically: by x, then by y. /*! compares two points lexigoraphically: by x, then by y.
* \param p1 The first point. * \param p1 The first point.
@ -126,15 +118,11 @@ public:
* SMALLER if x(p1) < x(p2), or if x(p1) = x(p2) and y(p1) < y(p2); * SMALLER if x(p1) < x(p2), or if x(p1) = x(p2) and y(p1) < y(p2);
* EQUAL if the two points are equal. * EQUAL if the two points are equal.
*/ */
Comparison_result operator() (const Point_2& p1, const Point_2& p2) const Comparison_result operator() (const Point_2& p1, const Point_2& p2) const {
{ if (p1.identical (p2)) return (EQUAL);
if (p1.identical (p2))
return (EQUAL);
Comparison_result res = CGAL::compare (p1.x(), p2.x()); Comparison_result res = CGAL::compare(p1.x(), p2.x());
if (res != EQUAL) return (res);
if (res != EQUAL)
return (res);
return (CGAL::compare (p1.y(), p2.y())); return (CGAL::compare (p1.y(), p2.y()));
} }
@ -142,69 +130,51 @@ public:
/*! obtains a Compare_xy_2 functor object. */ /*! obtains a Compare_xy_2 functor object. */
Compare_xy_2 compare_xy_2_object () const Compare_xy_2 compare_xy_2_object () const
{ { return Compare_xy_2(); }
return Compare_xy_2();
}
class Construct_min_vertex_2 class Construct_min_vertex_2 {
{
public: public:
/*! obtains the left endpoint of the \f$x\f$-monotone curve (segment). /*! obtains the left endpoint of the \f$x\f$-monotone curve (segment).
* \param cv The curve. * \param cv The curve.
* \return The left endpoint. * \return The left endpoint.
*/ */
const Point_2& operator() (const X_monotone_curve_2 & cv) const const Point_2& operator() (const X_monotone_curve_2 & cv) const
{ { return (cv.left()); }
return (cv.left());
}
}; };
/*! obtains a `Construct_min_vertex_2` functor object. */ /*! obtains a `Construct_min_vertex_2` functor object. */
Construct_min_vertex_2 construct_min_vertex_2_object () const Construct_min_vertex_2 construct_min_vertex_2_object () const
{ { return Construct_min_vertex_2(); }
return Construct_min_vertex_2();
}
class Construct_max_vertex_2 class Construct_max_vertex_2 {
{
public: public:
/*! obtains the right endpoint of the \f$x\f$-monotone curve (segment). /*! obtains the right endpoint of the \f$x\f$-monotone curve (segment).
* \param cv The curve. * \param cv The curve.
* \return The right endpoint. * \return The right endpoint.
*/ */
const Point_2& operator() (const X_monotone_curve_2 & cv) const const Point_2& operator() (const X_monotone_curve_2 & cv) const
{ { return (cv.right()); }
return (cv.right());
}
}; };
/*! obtains a Construct_max_vertex_2 functor object. */ /*! obtains a Construct_max_vertex_2 functor object. */
Construct_max_vertex_2 construct_max_vertex_2_object () const Construct_max_vertex_2 construct_max_vertex_2_object () const
{ { return Construct_max_vertex_2(); }
return Construct_max_vertex_2();
}
class Is_vertical_2 class Is_vertical_2 {
{
public: public:
/*! checks whether the given \f$x\f$-monotone curve is a vertical segment. /*! checks whether the given \f$x\f$-monotone curve is a vertical segment.
* \param cv The curve. * \param cv The curve.
* \return (true) if the curve is a vertical segment; (false) otherwise. * \return (true) if the curve is a vertical segment; (false) otherwise.
*/ */
bool operator() (const X_monotone_curve_2& cv) const bool operator() (const X_monotone_curve_2& cv) const
{ { return (cv.is_vertical()); }
return (cv.is_vertical());
}
}; };
/*! obtains an `Is_vertical_2` functor object. */ /*! obtains an `Is_vertical_2` functor object. */
Is_vertical_2 is_vertical_2_object () const Is_vertical_2 is_vertical_2_object () const
{ { return Is_vertical_2(); }
return Is_vertical_2();
}
class Compare_y_at_x_2 class Compare_y_at_x_2 {
{
public: public:
/*! returns the location of the given point with respect to the input curve. /*! returns the location of the given point with respect to the input curve.
* \param cv The curve. * \param cv The curve.
@ -214,23 +184,19 @@ public:
* LARGER if y(p) > cv(x(p)), i.e. the point is above the curve; * LARGER if y(p) > cv(x(p)), i.e. the point is above the curve;
* EQUAL if p lies on the curve. * EQUAL if p lies on the curve.
*/ */
Comparison_result operator() (const Point_2& p, Comparison_result operator()(const Point_2& p,
const X_monotone_curve_2& cv) const const X_monotone_curve_2& cv) const {
{ CGAL_precondition (cv.is_in_x_range(p));
CGAL_precondition (cv.is_in_x_range (p));
return (cv.point_position (p)); return (cv.point_position(p));
} }
}; };
/*! obtains a `Compare_y_at_x_2` functor object. */ /*! obtains a `Compare_y_at_x_2` functor object. */
Compare_y_at_x_2 compare_y_at_x_2_object () const Compare_y_at_x_2 compare_y_at_x_2_object () const
{ { return Compare_y_at_x_2(); }
return Compare_y_at_x_2();
}
class Compare_y_at_x_right_2 class Compare_y_at_x_right_2 {
{
public: public:
/*! compares the y value of two \f$x\f$-monotone curves immediately to the /*! compares the y value of two \f$x\f$-monotone curves immediately to the
* right of their intersection point. * right of their intersection point.
@ -244,30 +210,29 @@ public:
*/ */
Comparison_result operator() (const X_monotone_curve_2& cv1, Comparison_result operator() (const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
const Point_2& p) const const Point_2& p) const {
{
// Make sure that p lies on both curves, and that both are defined to its // Make sure that p lies on both curves, and that both are defined to its
// right (so their right endpoint is lexicographically larger than p). // right (so their right endpoint is lexicographically larger than p).
CGAL_precondition (cv1.point_position (p) == EQUAL && CGAL_precondition (cv1.point_position (p) == EQUAL &&
cv2.point_position (p) == EQUAL); cv2.point_position (p) == EQUAL);
if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) && if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) &&
(CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) (CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) {
{ //both cv1 and cv2 are vertical //both cv1 and cv2 are vertical
CGAL_precondition (!(cv1.right()).equals(p) && !(cv2.right()).equals(p)); CGAL_precondition (!(cv1.right()).equals(p) && !(cv2.right()).equals(p));
} }
else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) != EQUAL) && else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) != EQUAL) &&
(CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) (CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) {
{ //only cv1 is vertical //only cv1 is vertical
CGAL_precondition (!(cv1.right()).equals(p)); CGAL_precondition (!(cv1.right()).equals(p));
} }
else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) && else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) &&
(CGAL::compare (cv2.left().x(),cv2.right().x()) != EQUAL)) (CGAL::compare (cv2.left().x(),cv2.right().x()) != EQUAL)) {
{ //only cv2 is vertical //only cv2 is vertical
CGAL_precondition (!(cv2.right()).equals(p)); CGAL_precondition (!(cv2.right()).equals(p));
} }
else else {
{ //both cv1 and cv2 are non vertical //both cv1 and cv2 are non vertical
CGAL_precondition (CGAL::compare (cv1.right().x(),p.x()) == LARGER && CGAL_precondition (CGAL::compare (cv1.right().x(),p.x()) == LARGER &&
CGAL::compare (cv2.right().x(),p.x()) == LARGER); CGAL::compare (cv2.right().x(),p.x()) == LARGER);
} }
@ -278,12 +243,9 @@ public:
/*! obtains a `Compare_y_at_x_right_2` functor object. */ /*! obtains a `Compare_y_at_x_right_2` functor object. */
Compare_y_at_x_right_2 compare_y_at_x_right_2_object () const Compare_y_at_x_right_2 compare_y_at_x_right_2_object () const
{ { return Compare_y_at_x_right_2(); }
return Compare_y_at_x_right_2();
}
class Compare_y_at_x_left_2 class Compare_y_at_x_left_2 {
{
public: public:
/*! compares the \f$y\f$-value of two \f$x\f$-monotone curves immediately to /*! compares the \f$y\f$-value of two \f$x\f$-monotone curves immediately to
* the left of their intersection point. * the left of their intersection point.
@ -297,8 +259,7 @@ public:
*/ */
Comparison_result operator() (const X_monotone_curve_2& cv1, Comparison_result operator() (const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
const Point_2& p) const const Point_2& p) const {
{
// Make sure that p lies on both curves, and that both are defined to its // Make sure that p lies on both curves, and that both are defined to its
// left (so their left endpoint is lexicographically smaller than p). // left (so their left endpoint is lexicographically smaller than p).
@ -306,25 +267,25 @@ public:
cv2.point_position (p) == EQUAL); cv2.point_position (p) == EQUAL);
if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) && if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) &&
(CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) (CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) {
{ //both cv1 and cv2 are vertical //both cv1 and cv2 are vertical
CGAL_precondition (!(cv1.left()).equals(p) && !(cv2.left()).equals(p)); CGAL_precondition (!(cv1.left()).equals(p) && !(cv2.left()).equals(p));
} }
else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) != EQUAL) && else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) != EQUAL) &&
(CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) (CGAL::compare (cv2.left().x(),cv2.right().x()) == EQUAL)) {
{ //only cv1 is vertical //only cv1 is vertical
CGAL_precondition (!(cv1.left()).equals(p)); CGAL_precondition (!(cv1.left()).equals(p));
} }
else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) && else if ((CGAL::compare (cv1.left().x(),cv1.right().x()) == EQUAL) &&
(CGAL::compare (cv2.left().x(),cv2.right().x()) != EQUAL)) (CGAL::compare (cv2.left().x(),cv2.right().x()) != EQUAL)) {
{ //only cv2 is vertical //only cv2 is vertical
CGAL_precondition (!(cv2.left()).equals(p)); CGAL_precondition (!(cv2.left()).equals(p));
} }
else else {
{ //both cv1 and cv2 are non vertical //both cv1 and cv2 are non vertical
CGAL_precondition (CGAL::compare (cv1.left().x(),p.x()) == SMALLER && CGAL_precondition (CGAL::compare (cv1.left().x(),p.x()) == SMALLER &&
CGAL::compare (cv2.left().x(),p.x()) == SMALLER); CGAL::compare (cv2.left().x(),p.x()) == SMALLER);
} }
// Compare the two curves immediately to the left of p: // Compare the two curves immediately to the left of p:
return (cv1.compare_to_left (cv2, p)); return (cv1.compare_to_left (cv2, p));
} }
@ -332,12 +293,9 @@ public:
/*! obtains a `Compare_y_at_x_left_2` functor object. */ /*! obtains a `Compare_y_at_x_left_2` functor object. */
Compare_y_at_x_left_2 compare_y_at_x_left_2_object () const Compare_y_at_x_left_2 compare_y_at_x_left_2_object () const
{ { return Compare_y_at_x_left_2(); }
return Compare_y_at_x_left_2();
}
class Equal_2 class Equal_2 {
{
public: public:
/*! checks if the two \f$x\f$-monotone curves are the same (have the same /*! checks if the two \f$x\f$-monotone curves are the same (have the same
* graph). * graph).
@ -346,10 +304,8 @@ public:
* \return (true) if the two curves are the same; (false) otherwise. * \return (true) if the two curves are the same; (false) otherwise.
*/ */
bool operator() (const X_monotone_curve_2& cv1, bool operator() (const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const const X_monotone_curve_2& cv2) const {
{ if (&cv1 == &cv2) return (true);
if (&cv1 == &cv2)
return (true);
return (cv1.equals (cv2)); return (cv1.equals (cv2));
} }
@ -360,24 +316,20 @@ public:
* \return (true) if the two point are the same; (false) otherwise. * \return (true) if the two point are the same; (false) otherwise.
*/ */
bool operator() (const Point_2& p1, const Point_2& p2) const bool operator() (const Point_2& p1, const Point_2& p2) const
{ { return (p1.equals (p2)); }
return (p1.equals (p2));
}
}; };
/*! obtains an `Equal_2` functor object. */ /*! obtains an `Equal_2` functor object. */
Equal_2 equal_2_object () const Equal_2 equal_2_object () const
{ { return Equal_2(); }
return Equal_2();
}
//@} //@}
/// \name Functor definitions for approximations. Used by the landmarks /// \name Functor definitions for approximations. Used by the landmarks
// point-location strategy and the drawing procedure. // point-location strategy and the drawing procedure.
//@{ //@{
typedef double Approximate_number_type; using Approximate_number_type = double;
typedef CGAL::Cartesian<Approximate_number_type> Approximate_kernel; using Approximate_kernel = CGAL::Simple_cartesian<Approximate_number_type>;
typedef Approximate_kernel::Point_2 Approximate_point_2; using Approximate_point_2 = Approximate_kernel::Point_2;
class Approximate_2 { class Approximate_2 {
protected: protected:
@ -557,7 +509,7 @@ public:
*/ */
class Make_x_monotone_2 { class Make_x_monotone_2 {
private: private:
typedef Arr_circle_segment_traits_2<Kernel_, Filter> Self; using Self = Arr_circle_segment_traits_2<Kernel_, Filter>;
bool m_use_cache; bool m_use_cache;
@ -573,8 +525,7 @@ public:
* \return the past-the-end iterator. * \return the past-the-end iterator.
*/ */
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const {
{
// Increment the serial number of the curve cv, which will serve as its // Increment the serial number of the curve cv, which will serve as its
// unique identifier. // unique identifier.
unsigned int index = 0; unsigned int index = 0;
@ -591,7 +542,7 @@ public:
// Check the case of a degenerate circle (a point). // Check the case of a degenerate circle (a point).
const typename Kernel::Circle_2& circ = cv.supporting_circle(); const typename Kernel::Circle_2& circ = cv.supporting_circle();
CGAL::Sign sign_rad = CGAL::sign (circ.squared_radius()); CGAL::Sign sign_rad = CGAL::sign (circ.squared_radius());
CGAL_precondition (sign_rad != NEGATIVE); CGAL_precondition (sign_rad != NEGATIVE);
if (sign_rad == ZERO) { if (sign_rad == ZERO) {
@ -603,8 +554,8 @@ public:
// The curve is circular: compute the to vertical tangency points // The curve is circular: compute the to vertical tangency points
// of the supporting circle. // of the supporting circle.
Point_2 vpts[2]; Point_2 vpts[2];
unsigned int n_vpts = cv.vertical_tangency_points (vpts); unsigned int n_vpts = cv.vertical_tangency_points (vpts);
if (cv.is_full()) { if (cv.is_full()) {
CGAL_assertion (n_vpts == 2); CGAL_assertion (n_vpts == 2);
@ -674,8 +625,7 @@ public:
Make_x_monotone_2 make_x_monotone_2_object() const Make_x_monotone_2 make_x_monotone_2_object() const
{ return Make_x_monotone_2(m_use_cache); } { return Make_x_monotone_2(m_use_cache); }
class Split_2 class Split_2 {
{
public: public:
/*! splits a given \f$x\f$-monotone curve at a given point into two /*! splits a given \f$x\f$-monotone curve at a given point into two
@ -687,8 +637,7 @@ public:
* \pre `p` lies on cv but is not one of its end-points. * \pre `p` lies on cv but is not one of its end-points.
*/ */
void operator() (const X_monotone_curve_2& cv, const Point_2& p, void operator() (const X_monotone_curve_2& cv, const Point_2& p,
X_monotone_curve_2& c1, X_monotone_curve_2& c2) const X_monotone_curve_2& c1, X_monotone_curve_2& c2) const {
{
CGAL_precondition (cv.point_position(p)==EQUAL && CGAL_precondition (cv.point_position(p)==EQUAL &&
! p.equals (cv.source()) && ! p.equals (cv.source()) &&
! p.equals (cv.target())); ! p.equals (cv.target()));
@ -699,10 +648,7 @@ public:
}; };
/*! obtains a `Split_2` functor object. */ /*! obtains a `Split_2` functor object. */
Split_2 split_2_object () const Split_2 split_2_object () const { return Split_2(); }
{
return Split_2();
}
class Intersect_2 { class Intersect_2 {
private: private:
@ -730,8 +676,7 @@ public:
/*! obtains an `Intersect_2` functor object. */ /*! obtains an `Intersect_2` functor object. */
Intersect_2 intersect_2_object() const { return (Intersect_2(inter_map)); } Intersect_2 intersect_2_object() const { return (Intersect_2(inter_map)); }
class Are_mergeable_2 class Are_mergeable_2 {
{
public: public:
/*! checks whether it is possible to merge two given \f$x\f$-monotone curves. /*! checks whether it is possible to merge two given \f$x\f$-monotone curves.
* \param cv1 The first curve. * \param cv1 The first curve.
@ -742,24 +687,19 @@ public:
*/ */
bool operator() (const X_monotone_curve_2& cv1, bool operator() (const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const const X_monotone_curve_2& cv2) const
{ { return (cv1.can_merge_with (cv2)); }
return (cv1.can_merge_with (cv2));
}
}; };
/*! obtains an `Are_mergeable_2` functor object. */ /*! obtains an `Are_mergeable_2` functor object. */
Are_mergeable_2 are_mergeable_2_object () const Are_mergeable_2 are_mergeable_2_object () const
{ { return Are_mergeable_2(); }
return Are_mergeable_2();
}
/*! \class Merge_2 /*! \class Merge_2
* A functor that merges two \f$x\f$-monotone arcs into one. * A functor that merges two \f$x\f$-monotone arcs into one.
*/ */
class Merge_2 class Merge_2 {
{
protected: protected:
typedef Arr_circle_segment_traits_2<Kernel, Filter> Traits; using Traits = Arr_circle_segment_traits_2<Kernel, Filter>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits* m_traits; const Traits* m_traits;
@ -780,8 +720,7 @@ public:
*/ */
void operator() (const X_monotone_curve_2& cv1, void operator() (const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
X_monotone_curve_2& c) const X_monotone_curve_2& c) const {
{
CGAL_precondition(m_traits->are_mergeable_2_object()(cv2, cv1)); CGAL_precondition(m_traits->are_mergeable_2_object()(cv2, cv1));
c = cv1; c = cv1;
@ -790,20 +729,15 @@ public:
}; };
/*! obtains a `Merge_2` functor object. */ /*! obtains a `Merge_2` functor object. */
Merge_2 merge_2_object () const Merge_2 merge_2_object () const { return Merge_2(this); }
{
return Merge_2(this);
}
class Compare_endpoints_xy_2 class Compare_endpoints_xy_2 {
{
public: public:
/*! compares lexicogrphic the endpoints of a \f$x\f$-monotone curve. /*! compares lexicogrphic the endpoints of a \f$x\f$-monotone curve.
* \param cv the curve * \param cv the curve
* \return `SMALLER` if the curve is directed right, else return `LARGER`. * \return `SMALLER` if the curve is directed right, else return `LARGER`.
*/ */
Comparison_result operator()(const X_monotone_curve_2& cv) const Comparison_result operator()(const X_monotone_curve_2& cv) const {
{
if(cv.is_directed_right()) if(cv.is_directed_right())
return(SMALLER); return(SMALLER);
return (LARGER); return (LARGER);
@ -812,32 +746,25 @@ public:
/*! obtains a `Compare_endpoints_xy_2` functor object. */ /*! obtains a `Compare_endpoints_xy_2` functor object. */
Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const
{ { return Compare_endpoints_xy_2(); }
return Compare_endpoints_xy_2();
}
class Construct_opposite_2 class Construct_opposite_2 {
{
public: public:
/*! constructs an opposite \f$x\f$-monotone curve. /*! constructs an opposite \f$x\f$-monotone curve.
* \param cv the curve * \param cv the curve
* \return an opposite \f$x\f$-monotone curve. * \return an opposite \f$x\f$-monotone curve.
*/ */
X_monotone_curve_2 operator()(const X_monotone_curve_2& cv) const X_monotone_curve_2 operator()(const X_monotone_curve_2& cv) const
{ { return cv.construct_opposite(); }
return cv.construct_opposite();
}
}; };
/*! obtains a `Construct_opposite_2` functor object. */ /*! obtains a `Construct_opposite_2` functor object. */
Construct_opposite_2 construct_opposite_2_object() const Construct_opposite_2 construct_opposite_2_object() const
{ { return Construct_opposite_2(); }
return Construct_opposite_2();
}
class Trim_2 { class Trim_2 {
protected: protected:
typedef Arr_circle_segment_traits_2<Kernel, Filter> Traits; using Traits = Arr_circle_segment_traits_2<Kernel, Filter>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -860,8 +787,7 @@ public:
*/ */
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv, X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv,
const Point_2& src, const Point_2& src,
const Point_2& tgt)const const Point_2& tgt)const {
{
// make functor objects // make functor objects
CGAL_precondition_code(Compare_y_at_x_2 compare_y_at_x_2 = CGAL_precondition_code(Compare_y_at_x_2 compare_y_at_x_2 =
m_traits.compare_y_at_x_2_object()); m_traits.compare_y_at_x_2_object());
@ -885,7 +811,6 @@ public:
Trim_2 trim_2_object() const { return Trim_2(*this); } Trim_2 trim_2_object() const { return Trim_2(*this); }
// @} // @}
}; };
} // namespace CGAL } // namespace CGAL

View File

@ -40,55 +40,54 @@
namespace CGAL { namespace CGAL {
namespace internal{ namespace internal{
template <class CircularKernel>
class Non_x_monotonic_Circular_arc_2
: public CircularKernel::Circular_arc_2
{
typedef typename CircularKernel::FT FT;
typedef typename CircularKernel::Point_2 Point_2;
typedef typename CircularKernel::Line_2 Line_2;
typedef typename CircularKernel::Circle_2 Circle_2;
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
typedef typename CircularKernel::Circular_arc_2 Base; template <typename CircularKernel>
class Non_x_monotonic_Circular_arc_2 :
public CircularKernel::Circular_arc_2 {
using FT = typename CircularKernel::FT;
using Point_2 = typename CircularKernel::Point_2;
using Line_2 = typename CircularKernel::Line_2;
using Circle_2 = typename CircularKernel::Circle_2;
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
using Base = typename CircularKernel::Circular_arc_2;
public: public:
Non_x_monotonic_Circular_arc_2(): Base(){} Non_x_monotonic_Circular_arc_2(): Base(){}
Non_x_monotonic_Circular_arc_2(const Circle_2 &c): Base(c){} Non_x_monotonic_Circular_arc_2(const Circle_2& c): Base(c){}
// Not Documented // Not Documented
Non_x_monotonic_Circular_arc_2(const Circle_2 &support, Non_x_monotonic_Circular_arc_2(const Circle_2& support,
const Line_2 &l1, const bool b_l1, const Line_2& l1, const bool b_l1,
const Line_2 &l2, const bool b_l2) const Line_2& l2, const bool b_l2) :
: Base(support,l1,b_l1,l2,b_l2){} Base(support,l1,b_l1,l2,b_l2){}
// Not Documented // Not Documented
Non_x_monotonic_Circular_arc_2(const Circle_2 &c, Non_x_monotonic_Circular_arc_2(const Circle_2& c,
const Circle_2 &c1, const bool b_1, const Circle_2& c1, const bool b_1,
const Circle_2 &c2, const bool b_2) const Circle_2& c2, const bool b_2) :
: Base(c,c1,b_1,c2,b_2) Base(c,c1,b_1,c2,b_2)
{} {}
Non_x_monotonic_Circular_arc_2(const Point_2 &start, Non_x_monotonic_Circular_arc_2(const Point_2& start,
const Point_2 &middle, const Point_2& middle,
const Point_2 &end) const Point_2& end) :
: Base(start,middle,end) Base(start,middle,end)
{} {}
Non_x_monotonic_Circular_arc_2(const Circle_2 &support, Non_x_monotonic_Circular_arc_2(const Circle_2& support,
const Circular_arc_point_2 &begin, const Circular_arc_point_2& begin,
const Circular_arc_point_2 &end) const Circular_arc_point_2& end) :
: Base(support,begin,end) Base(support,begin,end)
{} {}
Non_x_monotonic_Circular_arc_2(const Point_2 &start, Non_x_monotonic_Circular_arc_2(const Point_2& start,
const Point_2 &end, const Point_2& end,
const FT &bulge) const FT& bulge) :
: Base(start,end,bulge) Base(start,end,bulge)
{} {}
Non_x_monotonic_Circular_arc_2(const Base& a) : Base(a) {} Non_x_monotonic_Circular_arc_2(const Base& a) : Base(a) {}
}; };
} //namespace internal } //namespace internal
@ -98,45 +97,40 @@ public:
template < typename CircularKernel > template < typename CircularKernel >
class Arr_circular_arc_traits_2 { class Arr_circular_arc_traits_2 {
CircularKernel ck; CircularKernel ck;
public: public:
using Kernel = CircularKernel;
using Curve_2 = internal::Non_x_monotonic_Circular_arc_2<CircularKernel>;
using X_monotone_curve_2 = typename CircularKernel::Circular_arc_2;
typedef CircularKernel Kernel; using Point = typename CircularKernel::Circular_arc_point_2;
typedef internal::Non_x_monotonic_Circular_arc_2<CircularKernel> Curve_2; using Point_2 = typename CircularKernel::Circular_arc_point_2;
typedef typename CircularKernel::Circular_arc_2 X_monotone_curve_2;
typedef typename CircularKernel::Circular_arc_point_2 Point; using Multiplicity = std::size_t;
typedef typename CircularKernel::Circular_arc_point_2 Point_2;
typedef unsigned int Multiplicity; using Has_left_category = CGAL::Tag_false;
using Has_merge_category = CGAL::Tag_false;
using Has_do_intersect_category = CGAL::Tag_false;
typedef CGAL::Tag_false Has_left_category; using Left_side_category = Arr_oblivious_side_tag;
typedef CGAL::Tag_false Has_merge_category; using Bottom_side_category = Arr_oblivious_side_tag;
typedef CGAL::Tag_false Has_do_intersect_category; using Top_side_category = Arr_oblivious_side_tag;
using Right_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Left_side_category; Arr_circular_arc_traits_2(const CircularKernel& k = CircularKernel()) : ck(k) {}
typedef Arr_oblivious_side_tag Bottom_side_category;
typedef Arr_oblivious_side_tag Top_side_category;
typedef Arr_oblivious_side_tag Right_side_category;
Arr_circular_arc_traits_2(const CircularKernel &k = CircularKernel()) using Compare_x_2 = typename CircularKernel::Compare_x_2;
: ck(k) {} using Compare_xy_2 = typename CircularKernel::Compare_xy_2;
using Compare_y_at_x_2 = typename CircularKernel::Compare_y_at_x_2;
typedef typename CircularKernel::Compare_x_2 Compare_x_2; using Compare_y_at_x_right_2 = typename CircularKernel::Compare_y_to_right_2;
typedef typename CircularKernel::Compare_xy_2 Compare_xy_2; using Construct_max_vertex_2 = typename CircularKernel::Construct_circular_max_vertex_2;
typedef typename CircularKernel::Compare_y_at_x_2 Compare_y_at_x_2; using Construct_min_vertex_2 = typename CircularKernel::Construct_circular_min_vertex_2;
typedef typename CircularKernel::Compare_y_to_right_2 Compare_y_at_x_right_2; using Equal_2 = typename CircularKernel::Equal_2;
typedef typename CircularKernel::Construct_circular_max_vertex_2
Construct_max_vertex_2;
typedef typename CircularKernel::Construct_circular_min_vertex_2
Construct_min_vertex_2;
typedef typename CircularKernel::Equal_2 Equal_2;
// typedef typename CircularKernel::Make_x_monotone_2 Make_x_monotone_2; // typedef typename CircularKernel::Make_x_monotone_2 Make_x_monotone_2;
typedef typename CircularKernel::Split_2 Split_2; using Split_2 = typename CircularKernel::Split_2;
typedef typename CircularKernel::Intersect_2 Intersect_2; using Intersect_2 = typename CircularKernel::Intersect_2;
typedef typename CircularKernel::Is_vertical_2 Is_vertical_2; using Is_vertical_2 = typename CircularKernel::Is_vertical_2;
Compare_x_2 compare_x_2_object() const Compare_x_2 compare_x_2_object() const
{ return ck.compare_x_2_object(); } { return ck.compare_x_2_object(); }
@ -160,26 +154,23 @@ public:
{ return ck.split_2_object(); } { return ck.split_2_object(); }
Intersect_2 intersect_2_object() const Intersect_2 intersect_2_object() const
{ return ck.intersect_2_object(); } { return ck.intersect_2_object(); }
Construct_max_vertex_2 construct_max_vertex_2_object() const Construct_max_vertex_2 construct_max_vertex_2_object() const
{ return ck.construct_circular_max_vertex_2_object(); } { return ck.construct_circular_max_vertex_2_object(); }
Construct_min_vertex_2 construct_min_vertex_2_object() const Construct_min_vertex_2 construct_min_vertex_2_object() const
{ return ck.construct_circular_min_vertex_2_object(); } { return ck.construct_circular_min_vertex_2_object(); }
Is_vertical_2 is_vertical_2_object() const Is_vertical_2 is_vertical_2_object() const
{ return ck.is_vertical_2_object(); } { return ck.is_vertical_2_object(); }
//! A functor for subdividing curves into x-monotone curves. //! A functor for subdividing curves into x-monotone curves.
class Make_x_monotone_2 { class Make_x_monotone_2 {
public: public:
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const Curve_2& arc, OutputIterator oi) const OutputIterator operator()(const Curve_2& arc, OutputIterator oi) const {
{ using Make_x_monotone_result = std::variant<Point_2, X_monotone_curve_2>;
typedef std::variant<Point_2, X_monotone_curve_2>
Make_x_monotone_result;
std::vector<Make_x_monotone_result> objs; std::vector<Make_x_monotone_result> objs;
CircularKernel().make_x_monotone_2_object()(arc, std::back_inserter(objs)); CircularKernel().make_x_monotone_2_object()(arc, std::back_inserter(objs));

View File

@ -41,515 +41,395 @@
#include <CGAL/Arr_tags.h> #include <CGAL/Arr_tags.h>
namespace CGAL { namespace CGAL {
namespace VariantFunctors{
// Takes an iterator range of Object(Line/Circular_arc/Point), namespace VariantFunctors {
// returns a variant of Line, Circular_arc, and Point_2.
template <class CK, class Arc1, class Arc2, class OutputIterator>
OutputIterator
object_to_object_variant(const std::vector<CGAL::Object>& res1,
OutputIterator res2)
{
typedef typename CK::Circular_arc_point_2 Point_2;
typedef std::variant<Arc1, Arc2> X_monotone_curve_2;
typedef std::variant<Point_2, X_monotone_curve_2>
Make_x_monotone_result;
for (auto it = res1.begin(); it != res1.end(); ++it) { // Takes an iterator range of Object(Line/Circular_arc/Point),
if (const Arc1* arc = CGAL::object_cast<Arc1>(&*it)) { // returns a variant of Line, Circular_arc, and Point_2.
std::variant<Arc1, Arc2> v = *arc; template <typename CK, typename Arc1, typename Arc2, typename OutputIterator>
*res2++ = Make_x_monotone_result(v); OutputIterator object_to_object_variant(const std::vector<CGAL::Object>& res1,
} OutputIterator res2) {
else if (const Arc2* line = CGAL::object_cast<Arc2>(&*it)) { using Point_2 = typename CK::Circular_arc_point_2;
std::variant<Arc1, Arc2> v = *line; using X_monotone_curve_2 = std::variant<Arc1, Arc2>;
*res2++ = Make_x_monotone_result(v); using Make_x_monotone_result = std::variant<Point_2, X_monotone_curve_2>;
}
else if (const Point_2* p = CGAL::object_cast<Point_2>(&*it)) { for (auto it = res1.begin(); it != res1.end(); ++it) {
*res2++ = Make_x_monotone_result(*p); if (const Arc1* arc = CGAL::object_cast<Arc1>(&*it)) {
} std::variant<Arc1, Arc2> v = *arc;
else CGAL_error(); *res2++ = Make_x_monotone_result(v);
}
else if (const Arc2* line = CGAL::object_cast<Arc2>(&*it)) {
std::variant<Arc1, Arc2> v = *line;
*res2++ = Make_x_monotone_result(v);
}
else if (const Point_2* p = CGAL::object_cast<Point_2>(&*it)) {
*res2++ = Make_x_monotone_result(*p);
}
else CGAL_error();
}
return res2;
}
template <typename CircularKernel, typename Arc1, typename Arc2>
class Compare_y_to_right_2 {
public:
using result_type = CGAL::Comparison_result;
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
result_type operator()(const std::variant<Arc1, Arc2>& a1,
const std::variant<Arc1, Arc2>& a2,
const Circular_arc_point_2& p) const {
if (const Arc1* arc1 = std::get_if<Arc1>(&a1)) {
if (const Arc1* arc2 = std::get_if<Arc1>(&a2)) {
return CircularKernel().compare_y_to_right_2_object()(*arc1, *arc2, p);
} }
return res2; else {
const Arc2* arc2e = std::get_if<Arc2>(&a2);
return CircularKernel().compare_y_to_right_2_object()(*arc1, *arc2e, p);
}
}
const Arc2* arc1 = std::get_if<Arc2>(&a1);
if (const Arc1* arc2 = std::get_if<Arc1>(&a2)) {
return CircularKernel().compare_y_to_right_2_object()(*arc1, *arc2, p);
}
const Arc2* arc2e = std::get_if<Arc2>(&a2);
return CircularKernel().compare_y_to_right_2_object()(*arc1, *arc2e, p);
}
};
template <typename CircularKernel>
class Variant_Equal_2 {
public:
template <typename T>
bool operator()(const T& a0, const T& a1) const
{ return CircularKernel().equal_2_object()(a0,a1); }
template <typename T1, typename T2>
bool operator()(const T1& , const T2&) const
{ return false; }
};
template <typename CircularKernel, class Arc1, class Arc2>
class Equal_2 : public CircularKernel::Equal_2 {
public:
using Curve_2 = std::variant< Arc1, Arc2>;
using result_type = bool;
using CircularKernel::Equal_2::operator();
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
using Line_arc_2 = typename CircularKernel::Line_arc_2;
using Circular_arc_2 = typename CircularKernel::Circular_arc_2;
using CK_Equal_2 = typename CircularKernel::Equal_2;
result_type operator()(const Circular_arc_point_2& p0,
const Circular_arc_point_2& p1) const
{ return CK_Equal_2()(p0, p1); }
result_type operator()(const Circular_arc_2& a0, const Circular_arc_2& a1) const
{ return CK_Equal_2()(a0, a1); }
result_type operator()(const Line_arc_2& a0, const Line_arc_2& a1) const
{ return CK_Equal_2()(a0, a1); }
result_type operator()(const Line_arc_2& /*a0*/, const Circular_arc_2& /*a1*/) const
{ return false; }
result_type operator()(const Circular_arc_2& /*a0*/, const Line_arc_2& /*a1*/) const
{ return false; }
result_type operator()(const Curve_2& a0, const Curve_2& a1) const
{ return std::visit(Variant_Equal_2<CircularKernel>(), a0, a1); }
};
template <typename CircularKernel, typename Arc1, typename Arc2>
class Compare_y_at_x_2 {
public:
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
using result_type = CGAL::Comparison_result;
result_type operator()(const Circular_arc_point_2& p,
const std::variant< Arc1, Arc2>& A1) const {
if (const Arc1* arc1 = std::get_if<Arc1>(&A1)){
return CircularKernel().compare_y_at_x_2_object()(p, *arc1);
}
else {
const Arc2* arc2 = std::get_if<Arc2>(&A1);
return CircularKernel().compare_y_at_x_2_object()(p, *arc2);
}
}
};
template <typename CircularKernel>
class Variant_Do_overlap_2 {
public:
template <typename T>
bool operator()(const T& a0, const T& a1) const
{ return CircularKernel().do_overlap_2_object()(a0, a1); }
template <typename T1, typename T2>
bool operator()(const T1&, const T2&) const
{ return false; }
};
template <typename CircularKernel, typename Arc1, typename Arc2>
class Do_overlap_2 {
public:
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
using result_type = bool;
result_type operator()(const std::variant< Arc1, Arc2>& A0,
const std::variant< Arc1, Arc2>& A1) const
{ return std::visit(Variant_Do_overlap_2<CircularKernel>(), A0, A1); }
};
//! A functor for subdividing curves into x-monotone curves.
template <typename CircularKernel, typename Arc1, typename Arc2>
class Make_x_monotone_2 {
public:
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
template <typename OutputIterator, typename Not_X_Monotone>
OutputIterator operator()(const std::variant<Arc1, Arc2, Not_X_Monotone>& A,
OutputIterator res) const {
if ( const Arc1* arc1 = std::get_if<Arc1>(&A)) {
return CircularKernel().make_x_monotone_2_object()(*arc1, res);
}
else {
const Arc2* arc2 = std::get_if<Arc2>(&A);
return CircularKernel().make_x_monotone_2_object()(*arc2, res);
}
}
};
template <typename CircularKernel, typename Arc1, typename Arc2>
class Intersect_2 {
public:
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
template <typename OutputIterator>
OutputIterator operator()(const std::variant< Arc1, Arc2>& c1,
const std::variant< Arc1, Arc2>& c2,
OutputIterator oi) const {
if (const Arc1* arc1 = std::get_if<Arc1>(&c1)) {
if ( const Arc1* arc2 = std::get_if<Arc1>(&c2)) {
return CircularKernel().intersect_2_object()(*arc1, *arc2, oi);
}
const Arc2* arc2 = std::get_if<Arc2>(&c2);
return CircularKernel().intersect_2_object()(*arc1, *arc2, oi);
} }
template <class CircularKernel, class Arc1, class Arc2> const Arc2* arc1e = std::get_if<Arc2>(&c1);
class Compare_y_to_right_2 if ( const Arc1* arc2 = std::get_if<Arc1>(&c2)) {
{ return CircularKernel().intersect_2_object()(*arc1e, *arc2, oi);
public: }
typedef CGAL::Comparison_result result_type; const Arc2* arc2 = std::get_if<Arc2>(&c2);
typedef typename CircularKernel::Circular_arc_point_2 return CircularKernel().intersect_2_object()(*arc1e, *arc2, oi);
Circular_arc_point_2;
result_type
operator()(const std::variant< Arc1, Arc2 > &a1,
const std::variant< Arc1, Arc2 > &a2,
const Circular_arc_point_2 &p) const
{
if ( const Arc1* arc1 = std::get_if<Arc1>( &a1 ) ){
if ( const Arc1* arc2 = std::get_if<Arc1>( &a2 ) ){
return CircularKernel()
.compare_y_to_right_2_object()(*arc1, *arc2, p);
}
else {
const Arc2* arc2e = std::get_if<Arc2>( &a2 );
return CircularKernel()
.compare_y_to_right_2_object()(*arc1, *arc2e, p);
}
}
const Arc2* arc1 = std::get_if<Arc2>( &a1 );
if ( const Arc1* arc2 = std::get_if<Arc1>( &a2 ) ){
return CircularKernel()
.compare_y_to_right_2_object()(*arc1, *arc2, p);
}
const Arc2* arc2e = std::get_if<Arc2>( &a2 );
return CircularKernel()
.compare_y_to_right_2_object()(*arc1, *arc2e, p);
}
};
template <class CircularKernel>
class Variant_Equal_2
{
public :
template < typename T >
bool
operator()(const T &a0, const T &a1) const
{
return CircularKernel().equal_2_object()(a0,a1);
}
template < typename T1, typename T2 >
bool
operator()(const T1 &, const T2 &) const
{
return false;
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Equal_2
: public CircularKernel::Equal_2
{
public:
typedef std::variant< Arc1, Arc2 > Curve_2;
typedef bool result_type;
using CircularKernel::Equal_2::operator();
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
typedef typename CircularKernel::Line_arc_2 Line_arc_2;
typedef typename CircularKernel::Circular_arc_2 Circular_arc_2;
typedef typename CircularKernel::Equal_2 CK_Equal_2;
result_type
operator() (const Circular_arc_point_2 &p0,
const Circular_arc_point_2 &p1) const
{ return CK_Equal_2()(p0, p1); }
result_type
operator() (const Circular_arc_2 &a0, const Circular_arc_2 &a1) const
{ return CK_Equal_2()(a0, a1); }
result_type
operator() (const Line_arc_2 &a0, const Line_arc_2 &a1) const
{ return CK_Equal_2()(a0, a1); }
result_type
operator() ( const Line_arc_2 &/*a0*/, const Circular_arc_2 &/*a1*/) const
{ return false; }
result_type
operator() ( const Circular_arc_2 &/*a0*/, const Line_arc_2 &/*a1*/) const
{ return false; }
result_type
operator()(const Curve_2 &a0, const Curve_2 &a1) const
{
return std::visit
( Variant_Equal_2<CircularKernel>(), a0, a1 );
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Compare_y_at_x_2
{
public:
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
typedef CGAL::Comparison_result result_type;
result_type
operator() (const Circular_arc_point_2 &p,
const std::variant< Arc1, Arc2 > &A1) const
{
if ( const Arc1* arc1 = std::get_if<Arc1>( &A1 ) ){
return CircularKernel().compare_y_at_x_2_object()(p, *arc1);
}
else {
const Arc2* arc2 = std::get_if<Arc2>( &A1 );
return CircularKernel().compare_y_at_x_2_object()(p, *arc2);
}
}
};
template <class CircularKernel>
class Variant_Do_overlap_2
{
public:
template < typename T >
bool
operator()(const T &a0, const T &a1) const
{
return CircularKernel().do_overlap_2_object()(a0, a1);
}
template < typename T1, typename T2 >
bool
operator()(const T1 &, const T2 &) const
{
return false;
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Do_overlap_2
{
public:
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
typedef bool result_type;
result_type
operator()(const std::variant< Arc1, Arc2 > &A0,
const std::variant< Arc1, Arc2 > &A1) const
{
return std::visit
( Variant_Do_overlap_2<CircularKernel>(), A0, A1 );
}
};
//! A functor for subdividing curves into x-monotone curves.
template <class CircularKernel, class Arc1, class Arc2>
class Make_x_monotone_2
{
public:
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
template < class OutputIterator,class Not_X_Monotone >
OutputIterator
operator()(const std::variant<Arc1, Arc2, Not_X_Monotone> &A,
OutputIterator res) const
{
if ( const Arc1* arc1 = std::get_if<Arc1>( &A ) ) {
return CircularKernel().
make_x_monotone_2_object()(*arc1, res);
}
else {
const Arc2* arc2 = std::get_if<Arc2>( &A );
return CircularKernel().
make_x_monotone_2_object()(*arc2, res);
}
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Intersect_2
{
public:
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
template < class OutputIterator >
OutputIterator
operator()(const std::variant< Arc1, Arc2 > &c1,
const std::variant< Arc1, Arc2 > &c2,
OutputIterator oi) const
{
if ( const Arc1* arc1 = std::get_if<Arc1>( &c1 ) ){
if ( const Arc1* arc2 = std::get_if<Arc1>( &c2 ) ){
return CircularKernel().intersect_2_object()(*arc1, *arc2, oi);
}
const Arc2* arc2 = std::get_if<Arc2>( &c2 );
return CircularKernel().intersect_2_object()(*arc1, *arc2, oi);
}
const Arc2* arc1e = std::get_if<Arc2>( &c1 );
if ( const Arc1* arc2 = std::get_if<Arc1>( &c2 ) ){
return CircularKernel().intersect_2_object()(*arc1e, *arc2, oi);
}
const Arc2* arc2 = std::get_if<Arc2>( &c2 );
return CircularKernel().intersect_2_object()(*arc1e, *arc2, oi);
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Split_2
{
public:
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
typedef void result_type;
result_type
operator()(const std::variant< Arc1, Arc2 > &A,
const Circular_arc_point_2 &p,
std::variant< Arc1, Arc2 > &ca1,
std::variant< Arc1, Arc2 > &ca2) const
{
// TODO : optimize by extracting the references from the variants ?
if ( const Arc1* arc1 = std::get_if<Arc1>( &A ) ){
Arc1 carc1;
Arc1 carc2;
CircularKernel().split_2_object()(*arc1, p, carc1, carc2);
ca1 = carc1;
ca2 = carc2;
return ;
}
else{
const Arc2* arc2 = std::get_if<Arc2>( &A );
Arc2 cline1;
Arc2 cline2;
CircularKernel().split_2_object()(*arc2, p, cline1, cline2);
ca1 = cline1;
ca2 = cline2;
return ;
}
}
};
template <class CircularKernel>
class Variant_Construct_min_vertex_2
{
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
public :
typedef Circular_arc_point_2 result_type;
//typedef const result_type& qualified_result_type;
template < typename T >
//std::remove_reference_t<qualified_result_type>
Circular_arc_point_2
operator()(const T &a) const
{
//CGAL_kernel_precondition(CircularKernel().compare_xy_2_object()(a.left(), a.right())==CGAL::SMALLER);
return CircularKernel().construct_circular_min_vertex_2_object()(a);
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Construct_min_vertex_2//: public Has_qrt
{
typedef typename CircularKernel::Circular_arc_point_2 Point_2;
public:
typedef Point_2 result_type;
//typedef const result_type& qualified_result_type;
//std::remove_reference_t<qualified_result_type>
result_type
operator() (const std::variant< Arc1, Arc2 > & cv) const
{
return std::visit
( Variant_Construct_min_vertex_2<CircularKernel>(), cv );
}
};
template <class CircularKernel>
class Variant_Construct_max_vertex_2
{
typedef typename CircularKernel::Circular_arc_point_2
Circular_arc_point_2;
public:
typedef Circular_arc_point_2 result_type;
//typedef const result_type& qualified_result_type;
template < typename T >
//std::remove_reference_t<qualified_result_type>
Circular_arc_point_2
operator()(const T &a) const
{
//CGAL_kernel_precondition(CircularKernel().compare_xy_2_object()(a.left(), a.right())==CGAL::SMALLER);
return (CircularKernel().construct_circular_max_vertex_2_object()(a));
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Construct_max_vertex_2//: public Has_qrt
{
typedef typename CircularKernel::Circular_arc_point_2 Point_2;
public:
/*! obtains the right endpoint of the x-monotone curve (segment).
* \param cv The curve.
* \return The right endpoint.
*/
typedef Point_2 result_type;
//typedef const result_type& qualified_result_type;
//std::remove_reference<qualified_result_type>
result_type
operator() (const std::variant< Arc1, Arc2 > & cv) const
{
return std::visit
( Variant_Construct_max_vertex_2<CircularKernel>(), cv );
}
};
template <class CircularKernel>
class Variant_Is_vertical_2
{
public:
template < typename T >
bool
operator()(const T &a) const
{
return CircularKernel().is_vertical_2_object()(a);
}
};
template <class CircularKernel, class Arc1, class Arc2>
class Is_vertical_2
{
public:
typedef bool result_type;
bool operator() (const std::variant< Arc1, Arc2 >& cv) const
{
return std::visit
( Variant_Is_vertical_2<CircularKernel>(), cv );
}
};
} }
};
template <typename CircularKernel, typename Arc1, typename Arc2>
class Split_2 {
public:
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
using result_type = void;
// an empty class used to have different types between Curve_2 and X_monotone_curve_2 result_type operator()(const std::variant< Arc1, Arc2>& A,
// in Arr_circular_line_arc_traits_2. const Circular_arc_point_2& p,
namespace internal_Argt_traits { std::variant< Arc1, Arc2>& ca1,
struct Not_X_Monotone{}; std::variant< Arc1, Arc2>& ca2) const {
inline std::ostream& operator << (std::ostream& os, const Not_X_Monotone&) // TODO : optimize by extracting the references from the variants ?
{return os;} if (const Arc1* arc1 = std::get_if<Arc1>(&A)) {
Arc1 carc1;
Arc1 carc2;
CircularKernel().split_2_object()(*arc1, p, carc1, carc2);
ca1 = carc1;
ca2 = carc2;
return ;
}
else {
const Arc2* arc2 = std::get_if<Arc2>(&A);
Arc2 cline1;
Arc2 cline2;
CircularKernel().split_2_object()(*arc2, p, cline1, cline2);
ca1 = cline1;
ca2 = cline2;
return ;
}
} }
};
/// Traits class for CGAL::Arrangement_2 (and similar) based on a CircularKernel. template <typename CircularKernel>
class Variant_Construct_min_vertex_2 {
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
public:
using result_type = Circular_arc_point_2;
// using qualified_result_type = const result_type& ;
template < typename CircularKernel> template <typename T>
class Arr_circular_line_arc_traits_2 { //std::remove_reference_t<qualified_result_type>
Circular_arc_point_2 operator()(const T& a) const {
//CGAL_kernel_precondition(CircularKernel().compare_xy_2_object()(a.left(), a.right())==CGAL::SMALLER);
return CircularKernel().construct_circular_min_vertex_2_object()(a);
}
};
typedef Arr_circular_line_arc_traits_2< CircularKernel > Self; template <typename CircularKernel, typename Arc1, typename Arc2>
class Construct_min_vertex_2 {
//: public Has_qrt
using Point_2 = typename CircularKernel::Circular_arc_point_2;
typedef typename CircularKernel::Line_arc_2 Arc1; public:
typedef typename CircularKernel::Circular_arc_2 Arc2; using result_type = Point_2;
// using qualified_result_type = const result_type&;
public: //std::remove_reference_t<qualified_result_type>
result_type operator() (const std::variant< Arc1, Arc2>& cv) const
{ return std::visit(Variant_Construct_min_vertex_2<CircularKernel>(), cv); }
};
typedef CircularKernel Kernel; template <typename CircularKernel>
typedef typename CircularKernel::Circular_arc_point_2 class Variant_Construct_max_vertex_2 {
Circular_arc_point_2; using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
public:
using result_type = Circular_arc_point_2;
// using qualified_result_type = const result_type&;
typedef typename CircularKernel::Circular_arc_point_2 Point; template <typename T>
typedef typename CircularKernel::Circular_arc_point_2 Point_2; //std::remove_reference_t<qualified_result_type>
Circular_arc_point_2 operator()(const T& a) const {
//CGAL_kernel_precondition(CircularKernel().compare_xy_2_object()(a.left(), a.right())==CGAL::SMALLER);
return (CircularKernel().construct_circular_max_vertex_2_object()(a));
}
};
typedef unsigned int Multiplicity; template <typename CircularKernel, typename Arc1, typename Arc2>
class Construct_max_vertex_2 {
//: public Has_qrt
using Point_2 = typename CircularKernel::Circular_arc_point_2;
typedef CGAL::Tag_false Has_left_category; public:
typedef CGAL::Tag_false Has_merge_category; /*! obtains the right endpoint of the x-monotone curve (segment).
typedef CGAL::Tag_false Has_do_intersect_category; * \param cv The curve.
* \return The right endpoint.
*/
using result_type = Point_2;
// using qualified_result_type = const result_type&;
typedef Arr_oblivious_side_tag Left_side_category; //std::remove_reference<qualified_result_type>
typedef Arr_oblivious_side_tag Bottom_side_category; result_type operator() (const std::variant<Arc1, Arc2>& cv) const
typedef Arr_oblivious_side_tag Top_side_category; { return std::visit(Variant_Construct_max_vertex_2<CircularKernel>(), cv); }
typedef Arr_oblivious_side_tag Right_side_category; };
typedef internal_Argt_traits::Not_X_Monotone Not_X_Monotone; template <typename CircularKernel>
class Variant_Is_vertical_2 {
public:
template <typename T>
bool operator()(const T& a) const
{ return CircularKernel().is_vertical_2_object()(a); }
};
typedef std::variant< Arc1, Arc2, Not_X_Monotone > Curve_2; template <typename CircularKernel, typename Arc1, typename Arc2>
typedef std::variant< Arc1, Arc2 > X_monotone_curve_2; class Is_vertical_2 {
public:
using result_type = bool;
private: bool operator() (const std::variant<Arc1, Arc2>& cv) const
CircularKernel ck; { return std::visit(Variant_Is_vertical_2<CircularKernel>(), cv); }
public: };
Arr_circular_line_arc_traits_2(const CircularKernel &k = CircularKernel()) }
: ck(k) {}
typedef typename CircularKernel::Compare_x_2 Compare_x_2; // an empty class used to have different types between Curve_2 and X_monotone_curve_2
typedef typename CircularKernel::Compare_xy_2 Compare_xy_2; // in Arr_circular_line_arc_traits_2.
typedef typename namespace internal_Argt_traits {
VariantFunctors::Construct_min_vertex_2<CircularKernel, Arc1, Arc2>
Construct_min_vertex_2;
typedef
VariantFunctors::Construct_max_vertex_2<CircularKernel, Arc1, Arc2>
Construct_max_vertex_2;
typedef VariantFunctors::Is_vertical_2<CircularKernel, Arc1, Arc2>
Is_vertical_2;
typedef VariantFunctors::Compare_y_at_x_2<CircularKernel, Arc1, Arc2>
Compare_y_at_x_2;
typedef VariantFunctors::Compare_y_to_right_2<CircularKernel, Arc1, Arc2>
Compare_y_at_x_right_2;
typedef VariantFunctors::Equal_2<CircularKernel, Arc1, Arc2>
Equal_2;
typedef VariantFunctors::Make_x_monotone_2<CircularKernel, Arc1, Arc2>
Make_x_monotone_2;
typedef VariantFunctors::Split_2<CircularKernel, Arc1, Arc2>
Split_2;
typedef VariantFunctors::Intersect_2<CircularKernel, Arc1, Arc2>
Intersect_2;
Compare_x_2 compare_x_2_object() const struct Not_X_Monotone{};
{ return ck.compare_x_2_object(); }
Compare_xy_2 compare_xy_2_object() const inline std::ostream& operator << (std::ostream& os, const Not_X_Monotone&) { return os; }
{ return ck.compare_xy_2_object(); }
Compare_y_at_x_2 compare_y_at_x_2_object() const }
{ return Compare_y_at_x_2(); }
Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const /// Traits class for CGAL::Arrangement_2 (and similar) based on a CircularKernel.
{ return Compare_y_at_x_right_2(); }
Equal_2 equal_2_object() const template <typename CircularKernel>
{ return Equal_2(); } class Arr_circular_line_arc_traits_2 {
using Self = Arr_circular_line_arc_traits_2<CircularKernel>;
Make_x_monotone_2 make_x_monotone_2_object() const using Arc1 = typename CircularKernel::Line_arc_2;
{ return Make_x_monotone_2(); } using Arc2 = typename CircularKernel::Circular_arc_2;
Split_2 split_2_object() const public:
{ return Split_2(); } using Kernel = CircularKernel;
using Circular_arc_point_2 = typename CircularKernel::Circular_arc_point_2;
Intersect_2 intersect_2_object() const using Point = typename CircularKernel::Circular_arc_point_2;
{ return Intersect_2(); } using Point_2 = typename CircularKernel::Circular_arc_point_2;
Construct_min_vertex_2 construct_min_vertex_2_object() const using Multiplicity = std::size_t;
{ return Construct_min_vertex_2(); }
Construct_max_vertex_2 construct_max_vertex_2_object() const using Has_left_category = CGAL::Tag_false;
{ return Construct_max_vertex_2(); } using Has_merge_category = CGAL::Tag_false;
using Has_do_intersect_category = CGAL::Tag_false;
Is_vertical_2 is_vertical_2_object() const using Left_side_category = Arr_oblivious_side_tag;
{ return Is_vertical_2();} using Bottom_side_category = Arr_oblivious_side_tag;
using Top_side_category = Arr_oblivious_side_tag;
using Right_side_category = Arr_oblivious_side_tag;
using Not_X_Monotone = internal_Argt_traits::Not_X_Monotone;
using Curve_2 = std::variant<Arc1, Arc2, Not_X_Monotone>;
using X_monotone_curve_2 = std::variant<Arc1, Arc2>;
private:
CircularKernel ck;
public:
Arr_circular_line_arc_traits_2(const CircularKernel& k = CircularKernel()) : ck(k) {}
using Compare_x_2 = typename CircularKernel::Compare_x_2;
using Compare_xy_2 = typename CircularKernel::Compare_xy_2;
using Construct_min_vertex_2 = typename VariantFunctors::Construct_min_vertex_2<CircularKernel, Arc1, Arc2>;
using Construct_max_vertex_2 = VariantFunctors::Construct_max_vertex_2<CircularKernel, Arc1, Arc2>;
using Is_vertical_2 = VariantFunctors::Is_vertical_2<CircularKernel, Arc1, Arc2>;
using Compare_y_at_x_2 = VariantFunctors::Compare_y_at_x_2<CircularKernel, Arc1, Arc2>;
using Compare_y_at_x_right_2 = VariantFunctors::Compare_y_to_right_2<CircularKernel, Arc1, Arc2>;
using Equal_2 = VariantFunctors::Equal_2<CircularKernel, Arc1, Arc2>;
using Make_x_monotone_2 = VariantFunctors::Make_x_monotone_2<CircularKernel, Arc1, Arc2>;
using Split_2 = VariantFunctors::Split_2<CircularKernel, Arc1, Arc2>;
using Intersect_2 = VariantFunctors::Intersect_2<CircularKernel, Arc1, Arc2>;
Compare_x_2 compare_x_2_object() const
{ return ck.compare_x_2_object(); }
Compare_xy_2 compare_xy_2_object() const
{ return ck.compare_xy_2_object(); }
Compare_y_at_x_2 compare_y_at_x_2_object() const
{ return Compare_y_at_x_2(); }
Compare_y_at_x_right_2 compare_y_at_x_right_2_object() const
{ return Compare_y_at_x_right_2(); }
Equal_2 equal_2_object() const
{ return Equal_2(); }
Make_x_monotone_2 make_x_monotone_2_object() const
{ return Make_x_monotone_2(); }
Split_2 split_2_object() const
{ return Split_2(); }
Intersect_2 intersect_2_object() const
{ return Intersect_2(); }
Construct_min_vertex_2 construct_min_vertex_2_object() const
{ return Construct_min_vertex_2(); }
Construct_max_vertex_2 construct_max_vertex_2_object() const
{ return Construct_max_vertex_2(); }
Is_vertical_2 is_vertical_2_object() const
{ return Is_vertical_2();}
}; };
} // namespace CGAL } // namespace CGAL

View File

@ -32,7 +32,7 @@
#include <boost/math/constants/constants.hpp> #include <boost/math/constants/constants.hpp>
#include <CGAL/Cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/tags.h> #include <CGAL/tags.h>
#include <CGAL/Arr_tags.h> #include <CGAL/Arr_tags.h>
#include <CGAL/Arr_enums.h> #include <CGAL/Arr_enums.h>
@ -59,37 +59,37 @@ namespace CGAL {
template <typename RatKernel, typename AlgKernel, typename NtTraits> template <typename RatKernel, typename AlgKernel, typename NtTraits>
class Arr_conic_traits_2 { class Arr_conic_traits_2 {
public: public:
typedef RatKernel Rat_kernel; using Rat_kernel = RatKernel;
typedef AlgKernel Alg_kernel; using Alg_kernel = AlgKernel;
typedef NtTraits Nt_traits; using Nt_traits = NtTraits;
typedef typename Rat_kernel::FT Rational; using Rational = typename Rat_kernel::FT;
typedef typename Rat_kernel::Point_2 Rat_point_2; using Rat_point_2 = typename Rat_kernel::Point_2;
typedef typename Rat_kernel::Segment_2 Rat_segment_2; using Rat_segment_2 = typename Rat_kernel::Segment_2;
typedef typename Rat_kernel::Line_2 Rat_line_2; using Rat_line_2 = typename Rat_kernel::Line_2;
typedef typename Rat_kernel::Circle_2 Rat_circle_2; using Rat_circle_2 = typename Rat_kernel::Circle_2;
typedef typename Alg_kernel::FT Algebraic; using Algebraic = typename Alg_kernel::FT;
typedef typename Alg_kernel::Point_2 Alg_point_2; using Alg_point_2 = typename Alg_kernel::Point_2;
typedef typename Nt_traits::Integer Integer; using Integer = typename Nt_traits::Integer;
// Category tags: // Category tags:
typedef Tag_true Has_left_category; using Has_left_category = Tag_true;
typedef Tag_true Has_merge_category; using Has_merge_category = Tag_true;
typedef Tag_false Has_do_intersect_category; using Has_do_intersect_category = Tag_false;
//typedef std::true_type Has_line_segment_constructor; //typedef std::true_type Has_line_segment_constructor;
typedef Arr_oblivious_side_tag Left_side_category; using Left_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Bottom_side_category; using Bottom_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Top_side_category; using Top_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Right_side_category; using Right_side_category = Arr_oblivious_side_tag;
// Traits objects: // Traits objects:
typedef Conic_arc_2<Rat_kernel, Alg_kernel, Nt_traits> Curve_2; using Curve_2 = Conic_arc_2<Rat_kernel, Alg_kernel, Nt_traits>;
typedef Conic_x_monotone_arc_2<Curve_2> X_monotone_curve_2; using X_monotone_curve_2 = Conic_x_monotone_arc_2<Curve_2>;
typedef Conic_point_2<Alg_kernel> Point_2; using Point_2 = Conic_point_2<Alg_kernel>;
typedef size_t Multiplicity; using Multiplicity = std::size_t;
private: private:
// Type definition for the intersection points mapping. // Type definition for the intersection points mapping.
@ -106,16 +106,14 @@ private:
} }
}; };
typedef std::pair<Point_2, Multiplicity> Intersection_point; using Intersection_point = std::pair<Point_2, Multiplicity>;
typedef std::list<Intersection_point> Intersection_list; using Intersection_list = std::list<Intersection_point>;
typedef std::map<Conic_pair, Intersection_list, Less_conic_pair> using Intersection_map = std::map<Conic_pair, Intersection_list, Less_conic_pair>;
Intersection_map; using Intersection_map_iterator = typename Intersection_map::iterator;
typedef typename Intersection_map::iterator Intersection_map_iterator;
using Shared_rat_kernel = std::shared_ptr<Rat_kernel>;
typedef std::shared_ptr<Rat_kernel> Shared_rat_kernel; using Shared_alg_kernel = std::shared_ptr<Alg_kernel>;
typedef std::shared_ptr<Alg_kernel> Shared_alg_kernel; using Shared_nt_traits = std::shared_ptr<Nt_traits>;
typedef std::shared_ptr<Nt_traits> Shared_nt_traits;
const Shared_rat_kernel m_rat_kernel; const Shared_rat_kernel m_rat_kernel;
const Shared_alg_kernel m_alg_kernel; const Shared_alg_kernel m_alg_kernel;
@ -127,10 +125,10 @@ private:
public: public:
/*! constructs default. /*! constructs default.
*/ */
Arr_conic_traits_2() Arr_conic_traits_2() :
: m_rat_kernel(std::make_shared<Rat_kernel>()), m_rat_kernel(std::make_shared<Rat_kernel>()),
m_alg_kernel(std::make_shared<Alg_kernel>()), m_alg_kernel(std::make_shared<Alg_kernel>()),
m_nt_traits(std::make_shared<Nt_traits>()) m_nt_traits(std::make_shared<Nt_traits>())
{} {}
/*! constructs from resources. /*! constructs from resources.
@ -360,8 +358,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2& xcv1, Comparison_result operator()(const X_monotone_curve_2& xcv1,
const X_monotone_curve_2& xcv2, const X_monotone_curve_2& xcv2,
const Point_2& p) const const Point_2& p) const {
{
// Make sure that p lies on both curves, and that both are defined to its // Make sure that p lies on both curves, and that both are defined to its
// left (so their left endpoint is lexicographically smaller than p). // left (so their left endpoint is lexicographically smaller than p).
CGAL_precondition(m_traits.contains_point(xcv1, p) && CGAL_precondition(m_traits.contains_point(xcv1, p) &&
@ -538,8 +535,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2& xcv1, Comparison_result operator()(const X_monotone_curve_2& xcv1,
const X_monotone_curve_2& xcv2, const X_monotone_curve_2& xcv2,
const Point_2& p) const const Point_2& p) const {
{
// Make sure that p lies on both curves, and that both are defined to its // Make sure that p lies on both curves, and that both are defined to its
// left (so their left endpoint is lexicographically smaller than p). // left (so their left endpoint is lexicographically smaller than p).
CGAL_precondition(m_traits.contains_point(xcv1, p) && CGAL_precondition(m_traits.contains_point(xcv1, p) &&
@ -703,8 +699,7 @@ public:
* \return `true` if the two curves are the same; `false` otherwise. * \return `true` if the two curves are the same; `false` otherwise.
*/ */
bool operator()(const X_monotone_curve_2& xcv1, bool operator()(const X_monotone_curve_2& xcv1,
const X_monotone_curve_2& xcv2) const const X_monotone_curve_2& xcv2) const {
{
if (&xcv1 == &xcv2) return true; if (&xcv1 == &xcv2) return true;
return equals(xcv1, xcv2); return equals(xcv1, xcv2);
} }
@ -924,8 +919,7 @@ public:
if (((cv.orientation() == COUNTERCLOCKWISE) && if (((cv.orientation() == COUNTERCLOCKWISE) &&
(start_pos == order_vpts)) || (start_pos == order_vpts)) ||
((cv.orientation() == CLOCKWISE) && (start_pos != order_vpts))) ((cv.orientation() == CLOCKWISE) && (start_pos != order_vpts))) {
{
ind_first = 1; ind_first = 1;
ind_second = 0; ind_second = 0;
} }
@ -1101,8 +1095,7 @@ public:
else if (m_traits.is_between_endpoints(xcv2, xcv1.source()) && else if (m_traits.is_between_endpoints(xcv2, xcv1.source()) &&
m_traits.is_between_endpoints(xcv2, xcv1.target()) && m_traits.is_between_endpoints(xcv2, xcv1.target()) &&
(m_traits.is_strictly_between_endpoints(xcv2, xcv1.source()) || (m_traits.is_strictly_between_endpoints(xcv2, xcv1.source()) ||
m_traits.is_strictly_between_endpoints(xcv2, xcv1.target()))) m_traits.is_strictly_between_endpoints(xcv2, xcv1.target()))) {
{
// Case 4 - *this: +-----------> // Case 4 - *this: +----------->
// arc: +================> // arc: +================>
overlap = xcv1; overlap = xcv1;
@ -1285,8 +1278,7 @@ public:
for (i = 0; i < n_xs; ++i) { for (i = 0; i < n_xs; ++i) {
for (j = 0; j < n_ys; ++j) { for (j = 0; j < n_ys; ++j) {
if (xcv1.is_on_supporting_conic(xs[i], ys[j]) && if (xcv1.is_on_supporting_conic(xs[i], ys[j]) &&
xcv2.is_on_supporting_conic(xs[i], ys[j])) xcv2.is_on_supporting_conic(xs[i], ys[j])) {
{
// Create the intersection point and set its generating conics. // Create the intersection point and set its generating conics.
Point_2 ip(xs[i], ys[j]); Point_2 ip(xs[i], ys[j]);
@ -1314,8 +1306,7 @@ public:
OutputIterator intersect(const X_monotone_curve_2& xcv1, OutputIterator intersect(const X_monotone_curve_2& xcv1,
const X_monotone_curve_2& xcv2, const X_monotone_curve_2& xcv2,
Intersection_map& inter_map, Intersection_map& inter_map,
OutputIterator oi) const OutputIterator oi) const {
{
if (m_traits.has_same_supporting_conic(xcv1, xcv2)) { if (m_traits.has_same_supporting_conic(xcv1, xcv2)) {
// Check for overlaps between the two arcs. // Check for overlaps between the two arcs.
X_monotone_curve_2 overlap; X_monotone_curve_2 overlap;
@ -1392,8 +1383,7 @@ public:
// both \f$x\f$-monotone arcs. // both \f$x\f$-monotone arcs.
for (auto iter = inter_list.begin(); iter != inter_list.end(); ++iter) { for (auto iter = inter_list.begin(); iter != inter_list.end(); ++iter) {
if (m_traits.is_between_endpoints(xcv1, (*iter).first) && if (m_traits.is_between_endpoints(xcv1, (*iter).first) &&
m_traits.is_between_endpoints(xcv2, (*iter).first)) m_traits.is_between_endpoints(xcv2, (*iter).first)) {
{
*oi++ = *iter; *oi++ = *iter;
} }
} }
@ -1481,8 +1471,7 @@ public:
*/ */
void operator()(const X_monotone_curve_2& xcv1, void operator()(const X_monotone_curve_2& xcv1,
const X_monotone_curve_2& xcv2, const X_monotone_curve_2& xcv2,
X_monotone_curve_2& xcv) const X_monotone_curve_2& xcv) const {
{
CGAL_precondition(m_traits.are_mergeable_2_object()(xcv2, xcv1)); CGAL_precondition(m_traits.are_mergeable_2_object()(xcv2, xcv1));
xcv = xcv1; xcv = xcv1;
merge(xcv, xcv2); merge(xcv, xcv2);
@ -1523,11 +1512,11 @@ public:
* point-location strategy and the drawing function. * point-location strategy and the drawing function.
*/ */
//@{ //@{
typedef double Approximate_number_type; using Approximate_number_type = double;
typedef CGAL::Cartesian<Approximate_number_type> Approximate_kernel; using Approximate_kernel = CGAL::Simple_cartesian<Approximate_number_type>;
typedef Approximate_kernel::Point_2 Approximate_point_2; using Approximate_point_2 = Approximate_kernel::Point_2;
class Approximate_curve_length_2 { class Approximate_length_2 {
protected: protected:
using Traits = Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits>; using Traits = Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits>;
@ -1537,7 +1526,7 @@ public:
/*! constructs /*! constructs
* \param traits the traits. * \param traits the traits.
*/ */
Approximate_curve_length_2(const Traits& traits) : m_traits(traits) {} Approximate_length_2(const Traits& traits) : m_traits(traits) {}
friend class Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits>; friend class Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits>;
@ -1557,7 +1546,7 @@ public:
private: private:
/*! obtains the segment length. /*! obtains the segment length.
*/ */
double segment_length(const X_monotone_curve_2& xcv) { double segment_length(const X_monotone_curve_2& xcv) const {
auto min_vertex = m_traits.construct_min_vertex_2_object(); auto min_vertex = m_traits.construct_min_vertex_2_object();
auto max_vertex = m_traits.construct_max_vertex_2_object(); auto max_vertex = m_traits.construct_max_vertex_2_object();
const auto& minv = min_vertex(xcv); const auto& minv = min_vertex(xcv);
@ -1597,7 +1586,7 @@ public:
/*! obtains the parabolic arc length. /*! obtains the parabolic arc length.
*/ */
double parabola_length(const X_monotone_curve_2& xcv) { double parabola_length(const X_monotone_curve_2& xcv) const {
double r_m, t_m, s_m, u_m, v_m, w_m; double r_m, t_m, s_m, u_m, v_m, w_m;
double cost, sint; double cost, sint;
double xs_t, ys_t, xt_t, yt_t; double xs_t, ys_t, xt_t, yt_t;
@ -1617,7 +1606,7 @@ public:
return d; return d;
} }
double ellipse_length(const X_monotone_curve_2& xcv) { double ellipse_length(const X_monotone_curve_2& xcv) const {
double r_m, t_m, s_m, u_m, v_m, w_m; double r_m, t_m, s_m, u_m, v_m, w_m;
double cost, sint; double cost, sint;
double xs_t, ys_t, xt_t, yt_t; double xs_t, ys_t, xt_t, yt_t;
@ -1638,7 +1627,7 @@ public:
return d; return d;
} }
double hyperbola_length(const X_monotone_curve_2& /* xcv */) { double hyperbola_length(const X_monotone_curve_2& /* xcv */) const {
CGAL_error_msg("Not implemented yet!"); CGAL_error_msg("Not implemented yet!");
double l(0.0); double l(0.0);
return l; return l;
@ -1901,8 +1890,7 @@ public:
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator approximate_parabola(const X_monotone_curve_2& xcv, OutputIterator approximate_parabola(const X_monotone_curve_2& xcv,
double error, OutputIterator oi, double error, OutputIterator oi,
bool l2r = true) bool l2r = true) const {
const {
// std::cout << "PARABOLA\n"; // std::cout << "PARABOLA\n";
auto min_vertex = m_traits.construct_min_vertex_2_object(); auto min_vertex = m_traits.construct_min_vertex_2_object();
auto max_vertex = m_traits.construct_max_vertex_2_object(); auto max_vertex = m_traits.construct_max_vertex_2_object();
@ -2104,8 +2092,7 @@ public:
*/ */
X_monotone_curve_2 operator()(const Curve_2& cv, X_monotone_curve_2 operator()(const Curve_2& cv,
const Point_2& source, const Point_2& target, const Point_2& source, const Point_2& target,
const Conic_id& id) const const Conic_id& id) const {
{
// Set the two endpoints. // Set the two endpoints.
X_monotone_curve_2 xcv(cv, id); X_monotone_curve_2 xcv(cv, id);
xcv.set_source(source); xcv.set_source(source);
@ -2122,8 +2109,7 @@ public:
* \return A segment connecting `source` and `target`. * \return A segment connecting `source` and `target`.
*/ */
X_monotone_curve_2 operator()(const Point_2& source, const Point_2& target) X_monotone_curve_2 operator()(const Point_2& source, const Point_2& target)
const const {
{
X_monotone_curve_2 xcv; X_monotone_curve_2 xcv;
// Set the basic properties. // Set the basic properties.
@ -2157,8 +2143,7 @@ public:
X_monotone_curve_2 operator()(const Algebraic& a, const Algebraic& b, X_monotone_curve_2 operator()(const Algebraic& a, const Algebraic& b,
const Algebraic& c, const Algebraic& c,
const Point_2& source, const Point_2& target) const Point_2& source, const Point_2& target)
const const {
{
auto cmp_xy = m_traits.m_alg_kernel->compare_xy_2_object(); auto cmp_xy = m_traits.m_alg_kernel->compare_xy_2_object();
Comparison_result res = cmp_xy(source, target); Comparison_result res = cmp_xy(source, target);
CGAL_precondition(res != EQUAL); CGAL_precondition(res != EQUAL);
@ -2238,8 +2223,7 @@ public:
*/ */
Curve_2 operator()(const Rational& r, const Rational& s, const Rational& t, Curve_2 operator()(const Rational& r, const Rational& s, const Rational& t,
const Rational& u, const Rational& v, const Rational& w) const Rational& u, const Rational& v, const Rational& w)
const const {
{
// Ensure that the given curve is an ellipse (4rs - t^2 is positive). // Ensure that the given curve is an ellipse (4rs - t^2 is positive).
CGAL_precondition(CGAL::sign(4*r*s - t*t) == POSITIVE); CGAL_precondition(CGAL::sign(4*r*s - t*t) == POSITIVE);
@ -2445,8 +2429,7 @@ public:
if (! m_traits.is_strictly_between_endpoints(arc, mp2) || if (! m_traits.is_strictly_between_endpoints(arc, mp2) ||
! m_traits.is_strictly_between_endpoints(arc, mp3) || ! m_traits.is_strictly_between_endpoints(arc, mp3) ||
! m_traits.is_strictly_between_endpoints(arc, mp4)) ! m_traits.is_strictly_between_endpoints(arc, mp4)) {
{
arc.reset_flags(); // invalid arc arc.reset_flags(); // invalid arc
return arc; return arc;
} }
@ -2853,8 +2836,7 @@ public:
* \pre both points must be interior and must lie on \c cv * \pre both points must be interior and must lie on \c cv
*/ */
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv, X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv,
const Point_2& src, const Point_2& tgt) const const Point_2& src, const Point_2& tgt) const {
{
// make functor objects // make functor objects
CGAL_precondition_code(Compare_y_at_x_2 compare_y_at_x_2 = CGAL_precondition_code(Compare_y_at_x_2 compare_y_at_x_2 =
m_traits.compare_y_at_x_2_object()); m_traits.compare_y_at_x_2_object());
@ -3084,16 +3066,14 @@ public:
const auto& target = cv.target(); const auto& target = cv.target();
// Make sure both endpoint lie on the supporting conic. // Make sure both endpoint lie on the supporting conic.
if (! is_on_supporting_conic(cv, source) || if (! is_on_supporting_conic(cv, source) ||
! is_on_supporting_conic(cv, target)) ! is_on_supporting_conic(cv, target)) {
{
cv.reset_flags(); // invalid arc cv.reset_flags(); // invalid arc
return; return;
} }
// Check whether we have a degree 2 curve. // Check whether we have a degree 2 curve.
if ((CGAL::sign(r) != ZERO) || (CGAL::sign(s) != ZERO) || if ((CGAL::sign(r) != ZERO) || (CGAL::sign(s) != ZERO) ||
(CGAL::sign(t) != ZERO)) (CGAL::sign(t) != ZERO)) {
{
if (cv.orientation() == COLLINEAR) { if (cv.orientation() == COLLINEAR) {
// Make sure the midpoint is on the line pair (thus making sure that // Make sure the midpoint is on the line pair (thus making sure that
// the two points are not taken from different lines). // the two points are not taken from different lines).
@ -3105,8 +3085,7 @@ public:
m_nt_traits->convert(u)) * p_mid.x() + m_nt_traits->convert(u)) * p_mid.x() +
(m_nt_traits->convert(s)*p_mid.y() + (m_nt_traits->convert(s)*p_mid.y() +
m_nt_traits->convert(v)) * p_mid.y() + m_nt_traits->convert(v)) * p_mid.y() +
m_nt_traits->convert(w)) != ZERO) m_nt_traits->convert(w)) != ZERO) {
{
cv.reset_flags(); // invalid arc cv.reset_flags(); // invalid arc
return; return;
} }
@ -3645,8 +3624,7 @@ public:
// Compute the degree of the underlying conic. // Compute the degree of the underlying conic.
if ((CGAL::sign(xcv.r()) != ZERO) || if ((CGAL::sign(xcv.r()) != ZERO) ||
(CGAL::sign(xcv.s()) != ZERO) || (CGAL::sign(xcv.s()) != ZERO) ||
(CGAL::sign(xcv.t()) != ZERO)) (CGAL::sign(xcv.t()) != ZERO)) {
{
xcv.set_flag(X_monotone_curve_2::DEGREE_2); xcv.set_flag(X_monotone_curve_2::DEGREE_2);
xcv.set_flag(X_monotone_curve_2::IS_SPECIAL_SEGMENT); xcv.set_flag(X_monotone_curve_2::IS_SPECIAL_SEGMENT);
} }
@ -3856,8 +3834,7 @@ public:
for (int j = 0; j < n_ys; ++j) { for (int j = 0; j < n_ys; ++j) {
if (CGAL::compare(m_nt_traits->convert(Integer(two*s)) * ys[j], if (CGAL::compare(m_nt_traits->convert(Integer(two*s)) * ys[j],
-(m_nt_traits->convert(t) * xs[i] + -(m_nt_traits->convert(t) * xs[i] +
m_nt_traits->convert(v))) == EQUAL) m_nt_traits->convert(v))) == EQUAL) {
{
ps[n++] = Point_2(xs[i], ys[j]); ps[n++] = Point_2(xs[i], ys[j]);
break; break;
} }
@ -4128,8 +4105,7 @@ public:
double& xs_t, double& ys_t, double& ts, double& xs_t, double& ys_t, double& ts,
double& xt_t, double& yt_t, double& tt, double& xt_t, double& yt_t, double& tt,
double& a, double& b, double& cx, double& cy, double& a, double& b, double& cx, double& cy,
bool l2r = true) bool l2r = true) const {
const {
auto min_vertex = construct_min_vertex_2_object(); auto min_vertex = construct_min_vertex_2_object();
auto max_vertex = construct_max_vertex_2_object(); auto max_vertex = construct_max_vertex_2_object();
const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv); const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv);
@ -4206,8 +4182,7 @@ public:
double& xs_t, double& ys_t, double& ts, double& xs_t, double& ys_t, double& ts,
double& xt_t, double& yt_t, double& tt, double& xt_t, double& yt_t, double& tt,
double& a, double& b, double& cx, double& cy, double& a, double& b, double& cx, double& cy,
bool l2r = true) bool l2r = true) const {
const {
auto min_vertex = construct_min_vertex_2_object(); auto min_vertex = construct_min_vertex_2_object();
auto max_vertex = construct_max_vertex_2_object(); auto max_vertex = construct_max_vertex_2_object();
const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv); const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv);

View File

@ -28,7 +28,7 @@
#include <variant> #include <variant>
#include <CGAL/config.h> #include <CGAL/config.h>
#include <CGAL/Cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/tags.h> #include <CGAL/tags.h>
#include <CGAL/tss.h> #include <CGAL/tss.h>
#include <CGAL/intersections.h> #include <CGAL/intersections.h>
@ -2856,7 +2856,7 @@ public:
/// \name Functor definitions for the landmarks point-location strategy. /// \name Functor definitions for the landmarks point-location strategy.
//@{ //@{
using Approximate_number_type = double; using Approximate_number_type = double;
using Approximate_kernel = CGAL::Cartesian<Approximate_number_type>; using Approximate_kernel = CGAL::Simple_cartesian<Approximate_number_type>;
using Approximate_point_2 = Arr_extended_direction_3<Approximate_kernel>; using Approximate_point_2 = Arr_extended_direction_3<Approximate_kernel>;
using Approximate_kernel_vector_3 = Approximate_kernel::Vector_3; using Approximate_kernel_vector_3 = Approximate_kernel::Vector_3;
using Approximate_kernel_direction_3 = Approximate_kernel::Direction_3; using Approximate_kernel_direction_3 = Approximate_kernel::Direction_3;

View File

@ -21,7 +21,6 @@
* Definition of the Bezier_bounding_rational_traits<Kernel> class. * Definition of the Bezier_bounding_rational_traits<Kernel> class.
*/ */
#include <CGAL/Cartesian.h>
#include <CGAL/Polygon_2_algorithms.h> #include <CGAL/Polygon_2_algorithms.h>
#include <CGAL/Arr_geometry_traits/de_Casteljau_2.h> #include <CGAL/Arr_geometry_traits/de_Casteljau_2.h>

View File

@ -41,9 +41,9 @@ class _One_root_point_2_rep {
friend class _One_root_point_2<NumberType_, Filter_>; friend class _One_root_point_2<NumberType_, Filter_>;
public: public:
typedef NumberType_ NT; using NT = NumberType_;
typedef _One_root_point_2_rep<NT, Filter_> Self; using Self = _One_root_point_2_rep<NT, Filter_>;
typedef Sqrt_extension<NT, NT, Tag_true,Boolean_tag<Filter_> > CoordNT; using CoordNT = Sqrt_extension<NT, NT, Tag_true,Boolean_tag<Filter_> >;
private: private:
CoordNT _x; // The coordinates. CoordNT _x; // The coordinates.
@ -70,18 +70,17 @@ public:
*/ */
template <typename NumberType_, bool Filter_> template <typename NumberType_, bool Filter_>
class _One_root_point_2 : class _One_root_point_2 :
public Handle_for<_One_root_point_2_rep<NumberType_, Filter_> > public Handle_for<_One_root_point_2_rep<NumberType_, Filter_>> {
{
public: public:
typedef NumberType_ NT; using NT = NumberType_;
typedef _One_root_point_2<NT, Filter_> Self; using Self = _One_root_point_2<NT, Filter_>;
private: private:
typedef _One_root_point_2_rep<NT, Filter_> Point_rep; using Point_rep = _One_root_point_2_rep<NT, Filter_>;
typedef Handle_for<Point_rep> Point_handle; using Point_handle = Handle_for<Point_rep>;
public: public:
typedef typename Point_rep::CoordNT CoordNT; using CoordNT = typename Point_rep::CoordNT;
/*! constructs default. */ /*! constructs default. */
_One_root_point_2() : Point_handle(Point_rep()) {} _One_root_point_2() : Point_handle(Point_rep()) {}
@ -106,8 +105,7 @@ public:
const CoordNT& y() const { return (this->ptr()->_y); } const CoordNT& y() const { return (this->ptr()->_y); }
/*! checks for equality. */ /*! checks for equality. */
bool equals(const Self& p) const bool equals(const Self& p) const {
{
if (this->identical(p)) return (true); if (this->identical(p)) return (true);
return (CGAL::compare(this->ptr()->_x, p.ptr()->_x) == EQUAL && return (CGAL::compare(this->ptr()->_x, p.ptr()->_x) == EQUAL &&
@ -119,8 +117,7 @@ public:
bool operator == (const Self& p) const { return equals(p); } bool operator == (const Self& p) const { return equals(p); }
/*! sets the point coordinates. */ /*! sets the point coordinates. */
void set(const NT& x, const NT& y) void set(const NT& x, const NT& y) {
{
this->copy_on_write(); this->copy_on_write();
this->ptr()->_x = CoordNT(x); this->ptr()->_x = CoordNT(x);
this->ptr()->_y = CoordNT(y); this->ptr()->_y = CoordNT(y);
@ -128,8 +125,7 @@ public:
} }
/*! sets the point coordinates. */ /*! sets the point coordinates. */
void set(const CoordNT& x, const CoordNT& y) void set(const CoordNT& x, const CoordNT& y) {
{
this->copy_on_write(); this->copy_on_write();
this->ptr()->_x = x; this->ptr()->_x = x;
this->ptr()->_y = y; this->ptr()->_y = y;
@ -141,8 +137,7 @@ public:
*/ */
template <typename NT, bool Filter> template <typename NT, bool Filter>
std::ostream& operator<<(std::ostream& os, std::ostream& operator<<(std::ostream& os,
const _One_root_point_2<NT, Filter>& p) const _One_root_point_2<NT, Filter>& p) {
{
os << CGAL::to_double(p.x()) << ' ' << CGAL::to_double(p.y()); os << CGAL::to_double(p.x()) << ' ' << CGAL::to_double(p.y());
return (os); return (os);
} }
@ -165,15 +160,15 @@ std::istream & operator >> (std::istream & is,
template <typename Kernel_, bool Filter_> template <typename Kernel_, bool Filter_>
class _Circle_segment_2 { class _Circle_segment_2 {
public: public:
typedef Kernel_ Kernel; using Kernel = Kernel_;
typedef typename Kernel::FT NT; using NT = typename Kernel::FT;
typedef _One_root_point_2<NT, Filter_> Point_2; using Point_2 = _One_root_point_2<NT, Filter_>;
typedef typename Kernel::Circle_2 Circle_2; using Circle_2 = typename Kernel::Circle_2;
typedef typename Kernel::Segment_2 Segment_2; using Segment_2 = typename Kernel::Segment_2;
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
protected: protected:
typedef typename Point_2::CoordNT CoordNT; using CoordNT = typename Point_2::CoordNT;
// Data members: // Data members:
Line_2 m_line; // The supporting line (for line segments). Line_2 m_line; // The supporting line (for line segments).
@ -234,8 +229,7 @@ public:
m_has_radius(false), m_has_radius(false),
m_source(source), m_source(source),
m_target(target), m_target(target),
m_orient(COLLINEAR) m_orient(COLLINEAR) {
{
CGAL_precondition(CGAL::compare(source.x() * line.a() + line.c(), CGAL_precondition(CGAL::compare(source.x() * line.a() + line.c(),
-source.y() * line.b()) == EQUAL); -source.y() * line.b()) == EQUAL);
@ -282,8 +276,7 @@ public:
m_has_radius(false), m_has_radius(false),
m_source(source), m_source(source),
m_target(target), m_target(target),
m_orient(circ.orientation()) m_orient(circ.orientation()) {
{
CGAL_assertion(m_orient != COLLINEAR); CGAL_assertion(m_orient != COLLINEAR);
CGAL_precondition CGAL_precondition
@ -315,8 +308,7 @@ public:
m_radius(r), m_radius(r),
m_source(source), m_source(source),
m_target(target), m_target(target),
m_orient(orient) m_orient(orient) {
{
CGAL_assertion(orient != COLLINEAR); CGAL_assertion(orient != COLLINEAR);
CGAL_precondition CGAL_precondition
@ -343,8 +335,7 @@ public:
m_is_full(false), m_is_full(false),
m_has_radius(false), m_has_radius(false),
m_source(p1.x(), p1.y()), m_source(p1.x(), p1.y()),
m_target(p3.x(), p3.y()) m_target(p3.x(), p3.y()) {
{
// Set the source and target. // Set the source and target.
NT x1 = p1.x(); NT x1 = p1.x();
NT y1 = p1.y(); NT y1 = p1.y();
@ -359,7 +350,7 @@ public:
// Compute the lines: A1*x + B1*y + C1 = 0, // Compute the lines: A1*x + B1*y + C1 = 0,
// and: A2*x + B2*y + C2 = 0, // and: A2*x + B2*y + C2 = 0,
// where: // where:
const NT _two = 2; const NT _two = 2;
const NT A1 = _two*(x1 - x2); const NT A1 = _two*(x1 - x2);
const NT B1 = _two*(y1 - y2); const NT B1 = _two*(y1 - y2);
@ -423,8 +414,7 @@ public:
/*! obtains the supporting line. /*! obtains the supporting line.
* \pre The curve orientation is COLLINEAR. * \pre The curve orientation is COLLINEAR.
*/ */
const Line_2& supporting_line() const const Line_2& supporting_line() const {
{
CGAL_precondition(m_orient == COLLINEAR); CGAL_precondition(m_orient == COLLINEAR);
return m_line; return m_line;
} }
@ -432,8 +422,7 @@ public:
/*! obtains the supporting circle. /*! obtains the supporting circle.
* \pre The curve orientation is not COLLINEAR. * \pre The curve orientation is not COLLINEAR.
*/ */
const Circle_2& supporting_circle() const const Circle_2& supporting_circle() const {
{
CGAL_precondition(m_orient != COLLINEAR); CGAL_precondition(m_orient != COLLINEAR);
return m_circ; return m_circ;
} }
@ -444,8 +433,7 @@ public:
/*! obtains the source point. /*! obtains the source point.
* \pre The curve is not a full circle. * \pre The curve is not a full circle.
*/ */
const Point_2& source() const const Point_2& source() const {
{
CGAL_precondition(! m_is_full); CGAL_precondition(! m_is_full);
return (m_source); return (m_source);
} }
@ -453,8 +441,7 @@ public:
/*! obtains the target point. /*! obtains the target point.
* \pre The curve is not a full circle. * \pre The curve is not a full circle.
*/ */
const Point_2& target() const const Point_2& target() const {
{
CGAL_precondition(! m_is_full); CGAL_precondition(! m_is_full);
return (m_target); return (m_target);
} }
@ -464,8 +451,7 @@ public:
* \pre The curve is circular. * \pre The curve is circular.
* \return The number of points (0, 1, or 2). * \return The number of points (0, 1, or 2).
*/ */
unsigned int vertical_tangency_points(Point_2* vpts) const unsigned int vertical_tangency_points(Point_2* vpts) const {
{
CGAL_precondition(m_orient != COLLINEAR); CGAL_precondition(m_orient != COLLINEAR);
unsigned int n_vpts = 0; unsigned int n_vpts = 0;
@ -519,8 +505,7 @@ private:
*/ */
unsigned int _ccw_vertical_tangency_points(const Point_2& src, unsigned int _ccw_vertical_tangency_points(const Point_2& src,
const Point_2& trg, const Point_2& trg,
Point_2* vpts) const Point_2* vpts) const {
{
unsigned int n_vpts = 0; unsigned int n_vpts = 0;
const NT& x0 = m_circ.center().x(); const NT& x0 = m_circ.center().x();
const NT& y0 = m_circ.center().y(); const NT& y0 = m_circ.center().y();
@ -547,8 +532,7 @@ private:
if ((qs % 4) == 1) { if ((qs % 4) == 1) {
// We collect the left tangency point when going from Q[1] to Q[2]: // We collect the left tangency point when going from Q[1] to Q[2]:
if (CGAL::compare(x0, trg.x()) != LARGER || if (CGAL::compare(x0, trg.x()) != LARGER ||
CGAL::compare(y0, trg.y()) != EQUAL) CGAL::compare(y0, trg.y()) != EQUAL) {
{
if (m_has_radius) if (m_has_radius)
vpts[n_vpts] = Point_2(CoordNT(x0 - m_radius), y0); vpts[n_vpts] = Point_2(CoordNT(x0 - m_radius), y0);
else else
@ -561,8 +545,7 @@ private:
else if ((qs % 4) == 3) { else if ((qs % 4) == 3) {
// We collect the right tangency point when going from Q[3] to Q[0]: // We collect the right tangency point when going from Q[3] to Q[0]:
if (CGAL::compare(x0, trg.x()) != SMALLER || if (CGAL::compare(x0, trg.x()) != SMALLER ||
CGAL::compare(y0, trg.y()) != EQUAL) CGAL::compare(y0, trg.y()) != EQUAL) {
{
if (m_has_radius) if (m_has_radius)
vpts[n_vpts] = Point_2(CoordNT(x0 + m_radius), y0); vpts[n_vpts] = Point_2(CoordNT(x0 + m_radius), y0);
else else
@ -581,8 +564,7 @@ private:
/*! obtains the index of the quarter-plane containing the given point, /*! obtains the index of the quarter-plane containing the given point,
* where the circle center is considered to be the origin. * where the circle center is considered to be the origin.
*/ */
int _quart_index(const Point_2& p) const int _quart_index(const Point_2& p) const {
{
// The plane looks like: // The plane looks like:
// //
// Q[1] : | Q[0]: // Q[1] : | Q[0]:
@ -608,8 +590,7 @@ private:
*/ */
template <typename Kernel, bool Filter> template <typename Kernel, bool Filter>
std::ostream& std::ostream&
operator<<(std::ostream& os, const _Circle_segment_2<Kernel, Filter>& c) operator<<(std::ostream& os, const _Circle_segment_2<Kernel, Filter>& c) {
{
if (c.orientation() == COLLINEAR) { if (c.orientation() == COLLINEAR) {
os<< "segment: " << c.source() << " -> " << c.target(); os<< "segment: " << c.source() << " -> " << c.target();
} }
@ -632,35 +613,33 @@ operator<<(std::ostream& os, const _Circle_segment_2<Kernel, Filter>& c)
template <typename Kernel_, bool Filter_> template <typename Kernel_, bool Filter_>
class _X_monotone_circle_segment_2 { class _X_monotone_circle_segment_2 {
public: public:
typedef Kernel_ Kernel; using Kernel = Kernel_;
typedef _X_monotone_circle_segment_2<Kernel, Filter_> Self; using Self = _X_monotone_circle_segment_2<Kernel, Filter_>;
typedef typename Kernel::FT NT; using NT = typename Kernel::FT;
typedef _One_root_point_2<NT, Filter_> Point_2; using Point_2 = _One_root_point_2<NT, Filter_>;
typedef typename Kernel::Circle_2 Circle_2; using Circle_2 = typename Kernel::Circle_2;
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
typedef typename Point_2::CoordNT CoordNT; using CoordNT = typename Point_2::CoordNT;
// Type definition for the intersection points mapping. // Type definition for the intersection points mapping.
typedef std::pair<unsigned int, unsigned int> Curve_id_pair; using Curve_id_pair = std::pair<unsigned int, unsigned int>;
typedef unsigned int Multiplicity; using Multiplicity = std::size_t;
typedef std::pair<Point_2, Multiplicity> Intersection_point; using Intersection_point = std::pair<Point_2, Multiplicity>;
typedef std::list<Intersection_point> Intersection_list; using Intersection_list = std::list<Intersection_point>;
/*! \struct Less functor for Curve_id_pair. /*! \struct Less functor for Curve_id_pair.
*/ */
struct Less_id_pair { struct Less_id_pair {
bool operator()(const Curve_id_pair& ip1, const Curve_id_pair& ip2) const bool operator()(const Curve_id_pair& ip1, const Curve_id_pair& ip2) const {
{
// Compare the pairs of IDs lexicographically. // Compare the pairs of IDs lexicographically.
return (ip1.first < ip2.first || return (ip1.first < ip2.first ||
(ip1.first == ip2.first && ip1.second < ip2.second)); (ip1.first == ip2.first && ip1.second < ip2.second));
} }
}; };
typedef std::map<Curve_id_pair, Intersection_list, Less_id_pair> using Intersection_map = std::map<Curve_id_pair, Intersection_list, Less_id_pair>;
Intersection_map; using Intersection_map_entry = typename Intersection_map::value_type;
typedef typename Intersection_map::value_type Intersection_map_entry; using Intersection_map_iterator = typename Intersection_map::iterator;
typedef typename Intersection_map::iterator Intersection_map_iterator;
protected: protected:
NT m_first; // The x-coordinate of the circle center. NT m_first; // The x-coordinate of the circle center.
@ -713,8 +692,7 @@ public:
m_third(line.c()), m_third(line.c()),
m_source(source), m_source(source),
m_target(target), m_target(target),
m_info(index << INDEX_SHIFT_BITS) m_info(index << INDEX_SHIFT_BITS) {
{
// Check if the segment is directed left or right: // Check if the segment is directed left or right:
Comparison_result res = CGAL::compare(source.x(), target.x()); Comparison_result res = CGAL::compare(source.x(), target.x());
@ -740,8 +718,7 @@ public:
const typename Kernel::Point_2& target) : const typename Kernel::Point_2& target) :
m_source(source.x(), source.y()), m_source(source.x(), source.y()),
m_target(target.x(), target.y()), m_target(target.x(), target.y()),
m_info(0) m_info(0) {
{
Line_2 line(source, target); Line_2 line(source, target);
m_first = line.a(); m_first = line.a();
m_second = line.b(); m_second = line.b();
@ -778,8 +755,7 @@ public:
m_third(circ.squared_radius()), m_third(circ.squared_radius()),
m_source(source), m_source(source),
m_target(target), m_target(target),
m_info(index << INDEX_SHIFT_BITS) m_info(index << INDEX_SHIFT_BITS) {
{
// Check if the segment is directed left or right: // Check if the segment is directed left or right:
Comparison_result res = CGAL::compare (source.x(), target.x()); Comparison_result res = CGAL::compare (source.x(), target.x());
@ -802,8 +778,7 @@ public:
/*! obtains the supporting line. /*! obtains the supporting line.
* \pre The arc is linear (a line segment). * \pre The arc is linear (a line segment).
*/ */
Line_2 supporting_line() const Line_2 supporting_line() const {
{
CGAL_precondition (is_linear()); CGAL_precondition (is_linear());
return (Line_2 (a(), b(), c())); return (Line_2 (a(), b(), c()));
} }
@ -811,8 +786,7 @@ public:
/*! obtains the supporting circle. /*! obtains the supporting circle.
* \pre The arc is circular. * \pre The arc is circular.
*/ */
Circle_2 supporting_circle() const Circle_2 supporting_circle() const {
{
CGAL_precondition (is_circular()); CGAL_precondition (is_circular());
typename Kernel::Point_2 center(x0(), y0()); typename Kernel::Point_2 center(x0(), y0());
@ -843,8 +817,7 @@ public:
/*! checks whether the given point is in the x-range of the arc. /*! checks whether the given point is in the x-range of the arc.
*/ */
bool is_in_x_range(const Point_2& p) const bool is_in_x_range(const Point_2& p) const {
{
Comparison_result res = CGAL::compare (p.x(), left().x()); Comparison_result res = CGAL::compare (p.x(), left().x());
if (res == SMALLER) return false; if (res == SMALLER) return false;
@ -858,8 +831,7 @@ public:
{ return ((m_info & IS_VERTICAL_SEGMENT_MASK) != 0); } { return ((m_info & IS_VERTICAL_SEGMENT_MASK) != 0); }
/*! obtains the orientation of the arc. */ /*! obtains the orientation of the arc. */
inline Orientation orientation() const inline Orientation orientation() const {
{
unsigned int or_ = (m_info & ORIENTATION_MASK); unsigned int or_ = (m_info & ORIENTATION_MASK);
if (or_ == COUNTERCLOCKWISE_CODE) return (CGAL::COUNTERCLOCKWISE); if (or_ == COUNTERCLOCKWISE_CODE) return (CGAL::COUNTERCLOCKWISE);
else if (or_ == CLOCKWISE_CODE) return (CGAL::CLOCKWISE); else if (or_ == CLOCKWISE_CODE) return (CGAL::CLOCKWISE);
@ -870,16 +842,14 @@ public:
/*! checks the position of a given point with respect to the arc. /*! checks the position of a given point with respect to the arc.
*/ */
Comparison_result point_position(const Point_2& p) const Comparison_result point_position(const Point_2& p) const {
{
if (is_linear()) return (_line_point_position(p)); if (is_linear()) return (_line_point_position(p));
else return (_circ_point_position (p)); else return (_circ_point_position (p));
} }
/*! compares the two arcs to the right of their intersection point. /*! compares the two arcs to the right of their intersection point.
*/ */
Comparison_result compare_to_right(const Self& cv, const Point_2& p) const Comparison_result compare_to_right(const Self& cv, const Point_2& p) const {
{
if (is_linear()) { if (is_linear()) {
if (cv.is_linear()) return (_lines_compare_to_right (cv, p)); if (cv.is_linear()) return (_lines_compare_to_right (cv, p));
Comparison_result res = cv._circ_line_compare_to_right (*this, p); Comparison_result res = cv._circ_line_compare_to_right (*this, p);
@ -894,8 +864,7 @@ public:
/*! compares the two arcs to the left of their intersection point. /*! compares the two arcs to the left of their intersection point.
*/ */
Comparison_result compare_to_left(const Self& cv, const Point_2& p) const Comparison_result compare_to_left(const Self& cv, const Point_2& p) const {
{
if (is_linear()) { if (is_linear()) {
if (cv.is_linear()) return (_lines_compare_to_left (cv, p)); if (cv.is_linear()) return (_lines_compare_to_left (cv, p));
Comparison_result res = cv._circ_line_compare_to_left(*this, p); Comparison_result res = cv._circ_line_compare_to_left(*this, p);
@ -910,8 +879,7 @@ public:
/*! checks whether the two arcs have the same supporting curve. /*! checks whether the two arcs have the same supporting curve.
*/ */
bool has_same_supporting_curve(const Self& cv) const bool has_same_supporting_curve(const Self& cv) const {
{
// Check if the curve indices are the same. // Check if the curve indices are the same.
if (_index() != 0 && _index() == cv._index()) return true; if (_index() != 0 && _index() == cv._index()) return true;
@ -950,8 +918,7 @@ public:
/*! checks whether the two curves are equal. /*! checks whether the two curves are equal.
*/ */
bool equals(const Self& cv) const bool equals(const Self& cv) const {
{
if (! this->has_same_supporting_curve(cv)) return false; if (! this->has_same_supporting_curve(cv)) return false;
if (is_linear()) { if (is_linear()) {
@ -969,8 +936,7 @@ public:
/*! splits the curve at a given point into two sub-arcs. /*! splits the curve at a given point into two sub-arcs.
*/ */
void split(const Point_2& p, Self& c1, Self& c2) const void split(const Point_2& p, Self& c1, Self& c2) const {
{
// Copy the properties of this arc to the sub-arcs. // Copy the properties of this arc to the sub-arcs.
c1 = *this; c1 = *this;
c2 = *this; c2 = *this;
@ -990,8 +956,7 @@ public:
*/ */
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator intersect(const Self& cv, OutputIterator oi, OutputIterator intersect(const Self& cv, OutputIterator oi,
Intersection_map* inter_map = nullptr) const Intersection_map* inter_map = nullptr) const {
{
// First check whether the two arcs have the same supporting curve. // First check whether the two arcs have the same supporting curve.
if (has_same_supporting_curve(cv)) { if (has_same_supporting_curve(cv)) {
// Check for overlaps between the two arcs. // Check for overlaps between the two arcs.
@ -1064,8 +1029,7 @@ public:
// Report only the intersection points that lie on both arcs. // Report only the intersection points that lie on both arcs.
for (auto iter = inter_list.begin(); iter != inter_list.end(); ++iter) { for (auto iter = inter_list.begin(); iter != inter_list.end(); ++iter) {
if (this->_is_between_endpoints (iter->first) && if (this->_is_between_endpoints (iter->first) &&
cv._is_between_endpoints (iter->first)) cv._is_between_endpoints (iter->first)) {
{
*oi++ = *iter; *oi++ = *iter;
} }
} }
@ -1075,8 +1039,7 @@ public:
/*! checks whether it is possible to merge our arc with the given arc. /*! checks whether it is possible to merge our arc with the given arc.
*/ */
bool can_merge_with(const Self& cv) const bool can_merge_with(const Self& cv) const {
{
// In order to merge the two arcs, they should have the same supporting // In order to merge the two arcs, they should have the same supporting
// curve. // curve.
if (! this->has_same_supporting_curve(cv)) return false; if (! this->has_same_supporting_curve(cv)) return false;
@ -1089,8 +1052,7 @@ public:
/*! merges our arc with the given arc. /*! merges our arc with the given arc.
* \pre The two arcs are mergeable. * \pre The two arcs are mergeable.
*/ */
void merge(const Self& cv) void merge(const Self& cv) {
{
CGAL_precondition(this->can_merge_with (cv)); CGAL_precondition(this->can_merge_with (cv));
// Check if we should extend the arc to the left or to the right. // Check if we should extend the arc to the left or to the right.
@ -1109,8 +1071,7 @@ public:
} }
/*! constructs an opposite arc. */ /*! constructs an opposite arc. */
Self construct_opposite() const Self construct_opposite() const {
{
Self opp_cv; Self opp_cv;
opp_cv.m_first = this->m_first; opp_cv.m_first = this->m_first;
opp_cv.m_second = this->m_second; opp_cv.m_second = this->m_second;
@ -1127,8 +1088,7 @@ public:
return (opp_cv); return (opp_cv);
} }
Bbox_2 bbox() const Bbox_2 bbox() const {
{
double x_min = to_double(left().x()); double x_min = to_double(left().x());
double x_max = to_double(right().x()); double x_max = to_double(right().x());
double y_min = to_double(left().y()); double y_min = to_double(left().y());
@ -1167,8 +1127,7 @@ protected:
/*! checks if the circular arc lies on the upper half of the supporting circle. /*! checks if the circular arc lies on the upper half of the supporting circle.
*/ */
inline bool _is_upper() const inline bool _is_upper() const {
{
Orientation orient = orientation(); Orientation orient = orientation();
bool dir_right = ((m_info & IS_DIRECTED_RIGHT_MASK) != 0); bool dir_right = ((m_info & IS_DIRECTED_RIGHT_MASK) != 0);
@ -1197,8 +1156,7 @@ protected:
/*! checks the position of a given point with respect to a line segment. /*! checks the position of a given point with respect to a line segment.
*/ */
Comparison_result _line_point_position(const Point_2& p) const Comparison_result _line_point_position(const Point_2& p) const {
{
// Check if we have a vertical segment. // Check if we have a vertical segment.
CGAL_precondition(is_in_x_range(p)); CGAL_precondition(is_in_x_range(p));
@ -1229,20 +1187,17 @@ protected:
/*! checks the position of a given point with respect to a circular arc. /*! checks the position of a given point with respect to a circular arc.
*/ */
Comparison_result _circ_point_position(const Point_2& p) const Comparison_result _circ_point_position(const Point_2& p) const {
{
Comparison_result c_res = CGAL::compare (p.y(), y0()); Comparison_result c_res = CGAL::compare (p.y(), y0());
if (_is_upper()) { if (_is_upper()) {
// Check if p lies below the "equator" (while the arc lies above it): // Check if p lies below the "equator" (while the arc lies above it):
if (c_res == SMALLER) if (c_res == SMALLER) return (SMALLER);
return (SMALLER);
} }
else { else {
// Check if p lies above the "equator" (while the arc lies below it): // Check if p lies above the "equator" (while the arc lies below it):
if (c_res == LARGER) if (c_res == LARGER) return (LARGER);
return (LARGER);
} }
// Check if p lies inside the supporting circle, namely we have to check // Check if p lies inside the supporting circle, namely we have to check
@ -1271,8 +1226,7 @@ protected:
/*! compares two line segments to the right of their intersection point. /*! compares two line segments to the right of their intersection point.
*/ */
Comparison_result _lines_compare_to_right(const Self& cv, Comparison_result _lines_compare_to_right(const Self& cv,
const Point_2& /* p */) const const Point_2& /* p */) const {
{
if (_index() != 0 && _index() == cv._index()) return (EQUAL); if (_index() != 0 && _index() == cv._index()) return (EQUAL);
// Special treatment for vertical segments: a vertical segment is larger // Special treatment for vertical segments: a vertical segment is larger
@ -1292,8 +1246,7 @@ protected:
* their intersection point. * their intersection point.
*/ */
Comparison_result _circ_line_compare_to_right(const Self& cv, Comparison_result _circ_line_compare_to_right(const Self& cv,
const Point_2& p) const const Point_2& p) const {
{
// A vertical segment lies above any other circle to the right of p: // A vertical segment lies above any other circle to the right of p:
if (cv.is_vertical()) return (SMALLER); if (cv.is_vertical()) return (SMALLER);
@ -1334,8 +1287,7 @@ protected:
/*! compares two circular arcs to the right of their intersection point. /*! compares two circular arcs to the right of their intersection point.
*/ */
Comparison_result _circs_compare_to_right(const Self& cv, Comparison_result _circs_compare_to_right(const Self& cv,
const Point_2& p) const const Point_2& p) const {
{
if (_index() != 0 && _index() == cv._index()) { if (_index() != 0 && _index() == cv._index()) {
// Check the case of comparing two circular arcs that originate from the // Check the case of comparing two circular arcs that originate from the
// same supporting circle. Their comparison result is not EQUAL only if // same supporting circle. Their comparison result is not EQUAL only if
@ -1413,13 +1365,11 @@ protected:
// Compare the slopes of the two tangents to the circles. // Compare the slopes of the two tangents to the circles.
Comparison_result slope_res; Comparison_result slope_res;
if (sign_slope1 == ZERO && sign_slope2 == ZERO) if (sign_slope1 == ZERO && sign_slope2 == ZERO) {
{
// Special case were both circles have a horizontal tangent: // Special case were both circles have a horizontal tangent:
slope_res = EQUAL; slope_res = EQUAL;
} }
else else {
{
// Actually compare the slopes. // Actually compare the slopes.
const bool swap_res = (sign_denom1 != sign_denom2); const bool swap_res = (sign_denom1 != sign_denom2);
const CoordNT A = NT(cv.y0() - y0())*p.x() + (y0()*cv.x0() - cv.y0()*x0()); const CoordNT A = NT(cv.y0() - y0())*p.x() + (y0()*cv.x0() - cv.y0()*x0());
@ -1466,8 +1416,7 @@ protected:
/*! compares two line segments to the left of their intersection point. /*! compares two line segments to the left of their intersection point.
*/ */
Comparison_result _lines_compare_to_left(const Self& cv, Comparison_result _lines_compare_to_left(const Self& cv,
const Point_2& ) const const Point_2& ) const {
{
if (_index() != 0 && _index() == cv._index()) return (EQUAL); if (_index() != 0 && _index() == cv._index()) return (EQUAL);
// Special treatment for vertical segments: a vertical segment is smaller // Special treatment for vertical segments: a vertical segment is smaller
@ -1489,8 +1438,7 @@ protected:
* their intersection point. * their intersection point.
*/ */
Comparison_result _circ_line_compare_to_left(const Self& cv, Comparison_result _circ_line_compare_to_left(const Self& cv,
const Point_2& p) const const Point_2& p) const {
{
// A vertical segment lies below any other circle to the left of p: // A vertical segment lies below any other circle to the left of p:
if (cv.is_vertical()) return (LARGER); if (cv.is_vertical()) return (LARGER);
@ -1534,8 +1482,7 @@ protected:
/*! compares the two arcs to the left of their intersection point. /*! compares the two arcs to the left of their intersection point.
*/ */
Comparison_result _circs_compare_to_left(const Self& cv, Comparison_result _circs_compare_to_left(const Self& cv,
const Point_2& p) const const Point_2& p) const {
{
if (_index() != 0 && _index() == cv._index()) { if (_index() != 0 && _index() == cv._index()) {
// Check the case of comparing two circular arcs that originate from the // Check the case of comparing two circular arcs that originate from the
// same supporting circle. Their comparison result is not EQUAL only if // same supporting circle. Their comparison result is not EQUAL only if
@ -1614,8 +1561,7 @@ protected:
// Compare the slopes of the two tangents to the circles. // Compare the slopes of the two tangents to the circles.
Comparison_result slope_res; Comparison_result slope_res;
if (sign_slope1 == ZERO && sign_slope2 == ZERO) if (sign_slope1 == ZERO && sign_slope2 == ZERO) {
{
// Special case were both circles have a horizontal tangent: // Special case were both circles have a horizontal tangent:
slope_res = EQUAL; slope_res = EQUAL;
} }
@ -1668,8 +1614,7 @@ protected:
/*! computes the intersections between two line segments. /*! computes the intersections between two line segments.
*/ */
void _lines_intersect(const Self& cv, void _lines_intersect(const Self& cv,
Intersection_list& inter_list) const Intersection_list& inter_list) const {
{
// The intersection of the lines: // The intersection of the lines:
// a1*x + b1*y + c1 = 0 and a2*x + b2*y + c2 = 0 , // a1*x + b1*y + c1 = 0 and a2*x + b2*y + c2 = 0 ,
// is given by: // is given by:
@ -1695,8 +1640,7 @@ protected:
* the supporting line of the segment cv. * the supporting line of the segment cv.
*/ */
void _circ_line_intersect(const Self& cv, void _circ_line_intersect(const Self& cv,
Intersection_list& inter_list) const Intersection_list& inter_list) const {
{
Point_2 p; Point_2 p;
unsigned int mult; unsigned int mult;
@ -1818,8 +1762,7 @@ protected:
/*! computes the intersections between two circles. /*! computes the intersections between two circles.
*/ */
void _circs_intersect(const Self& cv, Intersection_list& inter_list) const void _circs_intersect(const Self& cv, Intersection_list& inter_list) const {
{
Point_2 p; Point_2 p;
unsigned int mult; unsigned int mult;
@ -1884,8 +1827,7 @@ protected:
/*! checks if the given point lies on the arc. /*! checks if the given point lies on the arc.
* \pre p lies on the supporting curve. * \pre p lies on the supporting curve.
*/ */
bool _is_between_endpoints(const Point_2& p) const bool _is_between_endpoints(const Point_2& p) const {
{
if (is_linear()) { if (is_linear()) {
if (is_vertical()) { if (is_vertical()) {
// Check if the point is in the y-range of the arc. // Check if the point is in the y-range of the arc.
@ -1908,8 +1850,7 @@ protected:
// Check whether p lies on the upper or on the lower part of the circle. // Check whether p lies on the upper or on the lower part of the circle.
Comparison_result c_res = CGAL::compare(p.y(), y0()); Comparison_result c_res = CGAL::compare(p.y(), y0());
if ((_is_upper() && c_res == SMALLER) || (! _is_upper() && c_res == LARGER)) if ((_is_upper() && c_res == SMALLER) || (! _is_upper() && c_res == LARGER)) {
{
// The point lies on the other half of the circle: // The point lies on the other half of the circle:
return false; return false;
} }
@ -1921,8 +1862,7 @@ protected:
/*! checks whether the given point lies in the interior of the arc. /*! checks whether the given point lies in the interior of the arc.
* \pre p lies on the supporting curve. * \pre p lies on the supporting curve.
*/ */
bool _is_strictly_between_endpoints(const Point_2& p) const bool _is_strictly_between_endpoints(const Point_2& p) const {
{
if (p.equals (m_source) || p.equals (m_target)) return false; if (p.equals (m_source) || p.equals (m_target)) return false;
return (_is_between_endpoints(p)); return (_is_between_endpoints(p));
} }
@ -1932,8 +1872,7 @@ protected:
* \param overlap Output: The overlapping arc (if any). * \param overlap Output: The overlapping arc (if any).
* \return Whether we found an overlap. * \return Whether we found an overlap.
*/ */
bool _compute_overlap(const Self& cv, Self& overlap) const bool _compute_overlap(const Self& cv, Self& overlap) const {
{
// Check if the two arcs are identical. // Check if the two arcs are identical.
if (is_linear()) { if (is_linear()) {
// In case of line segments we can swap the source and target: // In case of line segments we can swap the source and target:
@ -1999,10 +1938,9 @@ protected:
return false; return false;
} }
public: public:
template <class OutputIterator> template <class OutputIterator>
void approximate(OutputIterator oi, unsigned int n) const void approximate(OutputIterator oi, unsigned int n) const {
{
const double x_left = CGAL::to_double(this->source().x()); const double x_left = CGAL::to_double(this->source().x());
const double y_left = CGAL::to_double(this->source().y()); const double y_left = CGAL::to_double(this->source().y());
@ -2045,8 +1983,7 @@ protected:
* \pre Both ps and pt lies on the arc and must conform with the current * \pre Both ps and pt lies on the arc and must conform with the current
* direction of the arc. * direction of the arc.
*/ */
Self trim(const Point_2& ps, const Point_2& pt) const Self trim(const Point_2& ps, const Point_2& pt) const {
{
Self arc = *this; Self arc = *this;
arc.m_source = ps; arc.m_source = ps;
@ -2063,8 +2000,7 @@ protected:
template <class Kernel, bool Filter> template <class Kernel, bool Filter>
std::ostream& std::ostream&
operator<<(std::ostream& os, operator<<(std::ostream& os,
const _X_monotone_circle_segment_2<Kernel, Filter> & arc) const _X_monotone_circle_segment_2<Kernel, Filter>& arc) {
{
if (! arc.is_linear()) if (! arc.is_linear())
os << "(" << arc.supporting_circle() << ") "; os << "(" << arc.supporting_circle() << ") ";

View File

@ -43,46 +43,41 @@ namespace CGAL {
// Traits class for CGAL::Arrangement_2 (and similar) based on a // Traits class for CGAL::Arrangement_2 (and similar) based on a
// CircularKernel. // CircularKernel.
template < typename CircularKernel > template <typename CircularKernel>
class Arr_line_arc_traits_2 { class Arr_line_arc_traits_2 {
CircularKernel ck; CircularKernel ck;
public: public:
using Kernel = CircularKernel;
using Curve_2 = typename CircularKernel::Line_arc_2;
using X_monotone_curve_2 = typename CircularKernel::Line_arc_2;
using Multiplicity = std::size_t;
typedef CircularKernel Kernel; using Point = typename CircularKernel::Circular_arc_point_2;
typedef typename CircularKernel::Line_arc_2 Curve_2; using Point_2 = typename CircularKernel::Circular_arc_point_2;
typedef typename CircularKernel::Line_arc_2 X_monotone_curve_2;
typedef unsigned int Multiplicity;
typedef typename CircularKernel::Circular_arc_point_2 Point; using Has_left_category = CGAL::Tag_false;
typedef typename CircularKernel::Circular_arc_point_2 Point_2; using Has_merge_category = CGAL::Tag_false;
using Has_do_intersect_category = CGAL::Tag_false;
typedef CGAL::Tag_false Has_left_category; using Left_side_category = Arr_oblivious_side_tag;
typedef CGAL::Tag_false Has_merge_category; using Bottom_side_category = Arr_oblivious_side_tag;
typedef CGAL::Tag_false Has_do_intersect_category; using Top_side_category = Arr_oblivious_side_tag;
using Right_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Left_side_category; Arr_line_arc_traits_2(const CircularKernel& k = CircularKernel()) : ck(k) {}
typedef Arr_oblivious_side_tag Bottom_side_category;
typedef Arr_oblivious_side_tag Top_side_category;
typedef Arr_oblivious_side_tag Right_side_category;
Arr_line_arc_traits_2(const CircularKernel &k = CircularKernel()) using Compare_x_2 = typename CircularKernel::Compare_x_2;
: ck(k) {} using Compare_xy_2 = typename CircularKernel::Compare_xy_2;
using Compare_y_at_x_2 = typename CircularKernel::Compare_y_at_x_2;
typedef typename CircularKernel::Compare_x_2 Compare_x_2; using Compare_y_at_x_right_2 = typename CircularKernel::Compare_y_to_right_2;
typedef typename CircularKernel::Compare_xy_2 Compare_xy_2; using Equal_2 = typename CircularKernel::Equal_2;
typedef typename CircularKernel::Compare_y_at_x_2 Compare_y_at_x_2; // using Make_x_monotone_2 = typename CircularKernel::Make_x_monotone_2;
typedef typename CircularKernel::Compare_y_to_right_2 Compare_y_at_x_right_2; using Split_2 = typename CircularKernel::Split_2;
typedef typename CircularKernel::Equal_2 Equal_2; using Construct_min_vertex_2 = typename CircularKernel::Construct_circular_min_vertex_2;
// typedef typename CircularKernel::Make_x_monotone_2 Make_x_monotone_2; using Construct_max_vertex_2 = typename CircularKernel::Construct_circular_max_vertex_2;
typedef typename CircularKernel::Split_2 Split_2; using Is_vertical_2 = typename CircularKernel::Is_vertical_2;
typedef typename CircularKernel::Construct_circular_min_vertex_2 using Intersect_2 = typename CircularKernel::Intersect_2;
Construct_min_vertex_2;
typedef typename CircularKernel::Construct_circular_max_vertex_2
Construct_max_vertex_2;
typedef typename CircularKernel::Is_vertical_2 Is_vertical_2;
typedef typename CircularKernel::Intersect_2 Intersect_2;
Compare_x_2 compare_x_2_object() const Compare_x_2 compare_x_2_object() const
{ return ck.compare_x_2_object(); } { return ck.compare_x_2_object(); }
@ -106,7 +101,7 @@ public:
{ return ck.split_2_object(); } { return ck.split_2_object(); }
Intersect_2 intersect_2_object() const Intersect_2 intersect_2_object() const
{ return ck.intersect_2_object(); } { return ck.intersect_2_object(); }
Construct_min_vertex_2 construct_min_vertex_2_object() const Construct_min_vertex_2 construct_min_vertex_2_object() const
{ return ck.construct_circular_min_vertex_2_object(); } { return ck.construct_circular_min_vertex_2_object(); }
@ -121,9 +116,8 @@ public:
class Make_x_monotone_2 { class Make_x_monotone_2 {
public: public:
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const Curve_2& line, OutputIterator oi) const OutputIterator operator()(const Curve_2& line, OutputIterator oi) const {
{ using Make_x_monotone_result = std::variant<Point_2, X_monotone_curve_2>;
typedef std::variant<Point_2, X_monotone_curve_2> Make_x_monotone_result;
*oi++ = Make_x_monotone_result(line); *oi++ = Make_x_monotone_result(line);
return oi; return oi;
} }
@ -137,4 +131,4 @@ public:
#include <CGAL/enable_warnings.h> #include <CGAL/enable_warnings.h>
#endif // CGAL_CIRCULAR_KERNEL_LINE_ARC_TRAITS_H #endif

View File

@ -28,7 +28,7 @@
#include <variant> #include <variant>
#include <CGAL/Cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/tags.h> #include <CGAL/tags.h>
#include <CGAL/intersections.h> #include <CGAL/intersections.h>
#include <CGAL/Arr_tags.h> #include <CGAL/Arr_tags.h>
@ -49,58 +49,55 @@ class Arr_linear_traits_2 : public Kernel_ {
friend class Arr_linear_object_2<Kernel_>; friend class Arr_linear_object_2<Kernel_>;
public: public:
typedef Kernel_ Kernel; using Kernel = Kernel_;
typedef typename Kernel::FT FT; using FT = typename Kernel::FT;
typedef typename Algebraic_structure_traits<FT>::Is_exact using Has_exact_division = typename Algebraic_structure_traits<FT>::Is_exact;
Has_exact_division;
// Category tags: // Category tags:
typedef Tag_true Has_left_category; using Has_left_category = Tag_true;
typedef Tag_true Has_merge_category; using Has_merge_category = Tag_true;
typedef Tag_false Has_do_intersect_category; using Has_do_intersect_category = Tag_false;
typedef Arr_open_side_tag Left_side_category; using Left_side_category = Arr_open_side_tag;
typedef Arr_open_side_tag Bottom_side_category; using Bottom_side_category = Arr_open_side_tag;
typedef Arr_open_side_tag Top_side_category; using Top_side_category = Arr_open_side_tag;
typedef Arr_open_side_tag Right_side_category; using Right_side_category = Arr_open_side_tag;
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
typedef typename Kernel::Ray_2 Ray_2; using Ray_2 = typename Kernel::Ray_2;
typedef typename Kernel::Segment_2 Segment_2; using Segment_2 = typename Kernel::Segment_2;
typedef CGAL::Segment_assertions<Arr_linear_traits_2<Kernel> > using Segment_assertions = CGAL::Segment_assertions<Arr_linear_traits_2<Kernel>>;
Segment_assertions;
/*! \class Representation of a linear with cached data. /*! \class Representation of a linear with cached data.
*/ */
class _Linear_object_cached_2 { class _Linear_object_cached_2 {
public: public:
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
typedef typename Kernel::Ray_2 Ray_2; using Ray_2 = typename Kernel::Ray_2;
typedef typename Kernel::Segment_2 Segment_2; using Segment_2 = typename Kernel::Segment_2;
typedef typename Kernel::Point_2 Point_2; using Point_2 = typename Kernel::Point_2;
protected: protected:
Line_2 l; // The supporting line. Line_2 l; // The supporting line.
Point_2 ps; // The source point (if exists). Point_2 ps; // The source point (if exists).
Point_2 pt; // The target point (if exists). Point_2 pt; // The target point (if exists).
bool has_source; // Is the source point valid bool has_source; // Is the source point valid
// (false for a line). // (false for a line).
bool has_target; // Is the target point valid bool has_target; // Is the target point valid
// (false for a line and for a ray). // (false for a line and for a ray).
bool is_right; // Is the object directed to the right bool is_right; // Is the object directed to the right
// (for segments and rays). // (for segments and rays).
bool is_vert; // Is this a vertical object. bool is_vert; // Is this a vertical object.
bool is_horiz; // Is this a horizontal object. bool is_horiz; // Is this a horizontal object.
bool has_pos_slope; // Does the supporting line has a positive bool has_pos_slope; // Does the supporting line has a positive
// slope (if all three flags is_vert, is_horiz // slope (if all three flags is_vert, is_horiz
// and has_pos_slope are false, then the line // and has_pos_slope are false, then the line
// has a negative slope). // has a negative slope).
bool is_degen; // Is the object degenerate (a single point). bool is_degen; // Is the object degenerate (a single point).
public: public:
/*! constructs default. /*! constructs default.
*/ */
_Linear_object_cached_2() : _Linear_object_cached_2() :
@ -121,8 +118,7 @@ public:
ps(source), ps(source),
pt(target), pt(target),
has_source(true), has_source(true),
has_target(true) has_target(true) {
{
Kernel kernel; Kernel kernel;
Comparison_result res = kernel.compare_xy_2_object()(source, target); Comparison_result res = kernel.compare_xy_2_object()(source, target);
@ -144,8 +140,7 @@ public:
*/ */
_Linear_object_cached_2(const Segment_2& seg) : _Linear_object_cached_2(const Segment_2& seg) :
has_source(true), has_source(true),
has_target(true) has_target(true) {
{
Kernel kernel; Kernel kernel;
CGAL_assertion_msg(! kernel.is_degenerate_2_object()(seg), CGAL_assertion_msg(! kernel.is_degenerate_2_object()(seg),
@ -172,8 +167,7 @@ public:
*/ */
_Linear_object_cached_2(const Ray_2& ray) : _Linear_object_cached_2(const Ray_2& ray) :
has_source(true), has_source(true),
has_target(false) has_target(false) {
{
Kernel kernel; Kernel kernel;
CGAL_assertion_msg(! kernel.is_degenerate_2_object()(ray), CGAL_assertion_msg(! kernel.is_degenerate_2_object()(ray),
@ -201,8 +195,7 @@ public:
_Linear_object_cached_2(const Line_2& ln) : _Linear_object_cached_2(const Line_2& ln) :
l(ln), l(ln),
has_source(false), has_source(false),
has_target(false) has_target(false) {
{
Kernel kernel; Kernel kernel;
CGAL_assertion_msg(! kernel.is_degenerate_2_object()(ln), CGAL_assertion_msg(! kernel.is_degenerate_2_object()(ln),
@ -226,8 +219,7 @@ public:
* \return `ARR_LEFT_BOUNDARY` if the left point is near the boundary; * \return `ARR_LEFT_BOUNDARY` if the left point is near the boundary;
* `ARR_INTERIOR` if the \f$x\f$-coordinate is finite. * `ARR_INTERIOR` if the \f$x\f$-coordinate is finite.
*/ */
Arr_parameter_space left_infinite_in_x() const Arr_parameter_space left_infinite_in_x() const {
{
if (is_vert || is_degen) return (ARR_INTERIOR); if (is_vert || is_degen) return (ARR_INTERIOR);
return (is_right) ? return (is_right) ?
@ -240,8 +232,7 @@ public:
* `ARR_INTERIOR` if the \f$y\f$-coordinate is finite. * `ARR_INTERIOR` if the \f$y\f$-coordinate is finite.
* `ARR_TOP_BOUNDARY` if the left point is at \f$y = +\infty\f$; * `ARR_TOP_BOUNDARY` if the left point is at \f$y = +\infty\f$;
*/ */
Arr_parameter_space left_infinite_in_y() const Arr_parameter_space left_infinite_in_y() const {
{
if (is_horiz || is_degen) return ARR_INTERIOR; if (is_horiz || is_degen) return ARR_INTERIOR;
if (is_vert) { if (is_vert) {
@ -263,8 +254,7 @@ public:
/*! obtains the (lexicographically) left endpoint. /*! obtains the (lexicographically) left endpoint.
* \pre The left point is finite. * \pre The left point is finite.
*/ */
const Point_2& left() const const Point_2& left() const {
{
CGAL_precondition(has_left()); CGAL_precondition(has_left());
return (is_right ? ps : pt); return (is_right ? ps : pt);
} }
@ -274,8 +264,7 @@ public:
* \pre p lies on the supporting line to the left of the right endpoint. * \pre p lies on the supporting line to the left of the right endpoint.
*/ */
void set_left(const Point_2& p, void set_left(const Point_2& p,
bool CGAL_assertion_code(check_validity) = true) bool CGAL_assertion_code(check_validity) = true) {
{
CGAL_precondition(! is_degen); CGAL_precondition(! is_degen);
CGAL_precondition_code(Kernel kernel); CGAL_precondition_code(Kernel kernel);
@ -296,8 +285,7 @@ public:
/*! sets the (lexicographically) left endpoint as infinite. /*! sets the (lexicographically) left endpoint as infinite.
*/ */
void set_left() void set_left() {
{
CGAL_precondition(! is_degen); CGAL_precondition(! is_degen);
if (is_right) has_source = false; if (is_right) has_source = false;
@ -308,8 +296,7 @@ public:
* \return `ARR_RIGHT_BOUNDARY` if the right point is near the boundary; * \return `ARR_RIGHT_BOUNDARY` if the right point is near the boundary;
* `ARR_INTERIOR` if the \f$x\f$-coordinate is finite. * `ARR_INTERIOR` if the \f$x\f$-coordinate is finite.
*/ */
Arr_parameter_space right_infinite_in_x() const Arr_parameter_space right_infinite_in_x() const {
{
if (is_vert || is_degen) return ARR_INTERIOR; if (is_vert || is_degen) return ARR_INTERIOR;
return (is_right) ? return (is_right) ?
@ -322,8 +309,7 @@ public:
* `ARR_INTERIOR` if the \f$y\f$-coordinate is finite. * `ARR_INTERIOR` if the \f$y\f$-coordinate is finite.
* `ARR_TOP_BOUNDARY` if the right point is at \f$y = +\infty\f$; * `ARR_TOP_BOUNDARY` if the right point is at \f$y = +\infty\f$;
*/ */
Arr_parameter_space right_infinite_in_y() const Arr_parameter_space right_infinite_in_y() const {
{
if (is_horiz || is_degen) return ARR_INTERIOR; if (is_horiz || is_degen) return ARR_INTERIOR;
if (is_vert) { if (is_vert) {
@ -345,8 +331,7 @@ public:
/*! obtains the (lexicographically) right endpoint. /*! obtains the (lexicographically) right endpoint.
* \pre The right endpoint is finite. * \pre The right endpoint is finite.
*/ */
const Point_2& right() const const Point_2& right() const {
{
CGAL_precondition(has_right()); CGAL_precondition(has_right());
return (is_right ? pt : ps); return (is_right ? pt : ps);
} }
@ -356,8 +341,7 @@ public:
* \pre p lies on the supporting line to the right of the left endpoint. * \pre p lies on the supporting line to the right of the left endpoint.
*/ */
void set_right(const Point_2& p, void set_right(const Point_2& p,
bool CGAL_assertion_code(check_validity) = true) bool CGAL_assertion_code(check_validity) = true) {
{
CGAL_precondition(! is_degen); CGAL_precondition(! is_degen);
CGAL_precondition_code(Kernel kernel); CGAL_precondition_code(Kernel kernel);
CGAL_precondition CGAL_precondition
@ -377,8 +361,7 @@ public:
/*! sets the (lexicographically) right endpoint as infinite. /*! sets the (lexicographically) right endpoint as infinite.
*/ */
void set_right() void set_right() {
{
CGAL_precondition(! is_degen); CGAL_precondition(! is_degen);
if (is_right) has_target = false; if (is_right) has_target = false;
@ -387,16 +370,14 @@ public:
/*! obtains the supporting line. /*! obtains the supporting line.
*/ */
const Line_2& supp_line() const const Line_2& supp_line() const {
{
CGAL_precondition(! is_degen); CGAL_precondition(! is_degen);
return (l); return (l);
} }
/*! checks whether the curve is vertical. /*! checks whether the curve is vertical.
*/ */
bool is_vertical() const bool is_vertical() const {
{
CGAL_precondition(! is_degen); CGAL_precondition(! is_degen);
return (is_vert); return (is_vert);
} }
@ -414,8 +395,7 @@ public:
* \return (true) is in the \f$x\f$-range of the segment; (false) if it is * \return (true) is in the \f$x\f$-range of the segment; (false) if it is
* not. * not.
*/ */
bool is_in_x_range(const Point_2& p) const bool is_in_x_range(const Point_2& p) const {
{
Kernel kernel; Kernel kernel;
typename Kernel_::Compare_x_2 compare_x = kernel.compare_x_2_object(); typename Kernel_::Compare_x_2 compare_x = kernel.compare_x_2_object();
Comparison_result res1; Comparison_result res1;
@ -454,8 +434,7 @@ public:
* \return (true) is in the \f$y\f$-range of the segment; (false) if it is * \return (true) is in the \f$y\f$-range of the segment; (false) if it is
* not. * not.
*/ */
bool is_in_y_range(const Point_2& p) const bool is_in_y_range(const Point_2& p) const {
{
CGAL_precondition(is_vertical()); CGAL_precondition(is_vertical());
Kernel kernel; Kernel kernel;
@ -483,8 +462,7 @@ public:
private: private:
/*! determines if the supporting line has a positive slope. /*! determines if the supporting line has a positive slope.
*/ */
bool _has_positive_slope() const bool _has_positive_slope() const {
{
if (is_vert) return true; if (is_vert) return true;
if (is_horiz) return false; if (is_horiz) return false;
@ -498,10 +476,10 @@ public:
public: public:
// Traits objects // Traits objects
typedef typename Kernel::Point_2 Point_2; using Point_2 = typename Kernel::Point_2;
typedef Arr_linear_object_2<Kernel> X_monotone_curve_2; using X_monotone_curve_2 = Arr_linear_object_2<Kernel>;
typedef Arr_linear_object_2<Kernel> Curve_2; using Curve_2 = Arr_linear_object_2<Kernel>;
typedef unsigned int Multiplicity; using Multiplicity = std::size_t;
public: public:
/*! constructs default. /*! constructs default.
@ -514,7 +492,7 @@ public:
/*! A functor that compares the \f$x\f$-coordinates of two points */ /*! A functor that compares the \f$x\f$-coordinates of two points */
class Compare_x_2 { class Compare_x_2 {
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -538,8 +516,7 @@ public:
* SMALLER if x(p1) < x(p2); * SMALLER if x(p1) < x(p2);
* EQUAL if x(p1) = x(p2). * EQUAL if x(p1) = x(p2).
*/ */
Comparison_result operator()(const Point_2& p1, const Point_2& p2) const Comparison_result operator()(const Point_2& p1, const Point_2& p2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
return (kernel.compare_x_2_object()(p1, p2)); return (kernel.compare_x_2_object()(p1, p2));
} }
@ -567,7 +544,7 @@ public:
class Trim_2 { class Trim_2 {
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -586,10 +563,8 @@ public:
public: public:
X_monotone_curve_2 operator()(const X_monotone_curve_2 xcv, X_monotone_curve_2 operator()(const X_monotone_curve_2 xcv,
const Point_2 src, const Point_2 src,
const Point_2 tgt) const Point_2 tgt) {
{ /* "Line_segment, line, and ray" will become line segments
/*
* "Line_segment, line, and ray" will become line segments
* when trimmed. * when trimmed.
*/ */
Equal_2 equal = Equal_2(); Equal_2 equal = Equal_2();
@ -619,7 +594,7 @@ public:
class Construct_opposite_2{ class Construct_opposite_2{
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -636,8 +611,7 @@ public:
friend class Arr_linear_traits_2<Kernel>; friend class Arr_linear_traits_2<Kernel>;
public: public:
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv) const X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv) const {
{
CGAL_precondition(! xcv.is_degenerate()); CGAL_precondition(! xcv.is_degenerate());
X_monotone_curve_2 opp_xcv; X_monotone_curve_2 opp_xcv;
@ -667,8 +641,7 @@ public:
* SMALLER if x(p1) < x(p2), or if x(p1) = x(p2) and y(p1) < y(p2); * SMALLER if x(p1) < x(p2), or if x(p1) = x(p2) and y(p1) < y(p2);
* EQUAL if the two points are equal. * EQUAL if the two points are equal.
*/ */
Comparison_result operator()(const Point_2& p1, const Point_2& p2) const Comparison_result operator()(const Point_2& p1, const Point_2& p2) const {
{
Kernel kernel; Kernel kernel;
return (kernel.compare_xy_2_object()(p1, p2)); return (kernel.compare_xy_2_object()(p1, p2));
} }
@ -685,8 +658,7 @@ public:
* \pre The left end of cv is a valid (bounded) point. * \pre The left end of cv is a valid (bounded) point.
* \return The left endpoint. * \return The left endpoint.
*/ */
const Point_2& operator()(const X_monotone_curve_2& cv) const const Point_2& operator()(const X_monotone_curve_2& cv) const {
{
CGAL_precondition(! cv.is_degenerate()); CGAL_precondition(! cv.is_degenerate());
CGAL_precondition(cv.has_left()); CGAL_precondition(cv.has_left());
@ -706,8 +678,7 @@ public:
* \pre The right end of cv is a valid (bounded) point. * \pre The right end of cv is a valid (bounded) point.
* \return The right endpoint. * \return The right endpoint.
*/ */
const Point_2& operator()(const X_monotone_curve_2& cv) const const Point_2& operator()(const X_monotone_curve_2& cv) const {
{
CGAL_precondition(! cv.is_degenerate()); CGAL_precondition(! cv.is_degenerate());
CGAL_precondition(cv.has_right()); CGAL_precondition(cv.has_right());
@ -726,8 +697,7 @@ public:
* \param cv The curve. * \param cv The curve.
* \return (true) if the curve is a vertical segment; (false) otherwise. * \return (true) if the curve is a vertical segment; (false) otherwise.
*/ */
bool operator()(const X_monotone_curve_2& cv) const bool operator()(const X_monotone_curve_2& cv) const {
{
CGAL_precondition(! cv.is_degenerate()); CGAL_precondition(! cv.is_degenerate());
return (cv.is_vertical()); return (cv.is_vertical());
} }
@ -741,7 +711,7 @@ public:
*/ */
class Compare_y_at_x_2 { class Compare_y_at_x_2 {
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -767,8 +737,7 @@ public:
* EQUAL if p lies on the curve. * EQUAL if p lies on the curve.
*/ */
Comparison_result operator()(const Point_2& p, Comparison_result operator()(const Point_2& p,
const X_monotone_curve_2& cv) const const X_monotone_curve_2& cv) const {
{
CGAL_precondition(! cv.is_degenerate()); CGAL_precondition(! cv.is_degenerate());
CGAL_precondition(cv.is_in_x_range(p)); CGAL_precondition(cv.is_in_x_range(p));
@ -809,8 +778,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2& cv1, Comparison_result operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
const Point_2& CGAL_precondition_code(p)) const const Point_2& CGAL_precondition_code(p)) const {
{
CGAL_precondition(! cv1.is_degenerate()); CGAL_precondition(! cv1.is_degenerate());
CGAL_precondition(! cv2.is_degenerate()); CGAL_precondition(! cv2.is_degenerate());
@ -861,8 +829,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2& cv1, Comparison_result operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
const Point_2& CGAL_precondition_code(p)) const const Point_2& CGAL_precondition_code(p)) const {
{
CGAL_precondition(! cv1.is_degenerate()); CGAL_precondition(! cv1.is_degenerate());
CGAL_precondition(! cv2.is_degenerate()); CGAL_precondition(! cv2.is_degenerate());
@ -906,8 +873,7 @@ public:
* \return (true) if the two curves are the same; (false) otherwise. * \return (true) if the two curves are the same; (false) otherwise.
*/ */
bool operator()(const X_monotone_curve_2& cv1, bool operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const const X_monotone_curve_2& cv2) const {
{
CGAL_precondition(! cv1.is_degenerate()); CGAL_precondition(! cv1.is_degenerate());
CGAL_precondition(! cv2.is_degenerate()); CGAL_precondition(! cv2.is_degenerate());
@ -918,17 +884,13 @@ public:
if (! equal(cv1.supp_line(), cv2.supp_line()) && if (! equal(cv1.supp_line(), cv2.supp_line()) &&
! equal(cv1.supp_line(), ! equal(cv1.supp_line(),
kernel.construct_opposite_line_2_object()(cv2.supp_line()))) kernel.construct_opposite_line_2_object()(cv2.supp_line())))
{
return false; return false;
}
// Check that either the two left endpoints are at infinity, or they // Check that either the two left endpoints are at infinity, or they
// are bounded and equal. // are bounded and equal.
if ((cv1.has_left() != cv2.has_left()) || if ((cv1.has_left() != cv2.has_left()) ||
(cv1.has_left() && ! equal(cv1.left(), cv2.left()))) (cv1.has_left() && ! equal(cv1.left(), cv2.left())))
{
return false; return false;
}
// Check that either the two right endpoints are at infinity, or they // Check that either the two right endpoints are at infinity, or they
// are bounded and equal. // are bounded and equal.
@ -941,8 +903,7 @@ public:
* \param p2 The second point. * \param p2 The second point.
* \return (true) if the two point are the same; (false) otherwise. * \return (true) if the two point are the same; (false) otherwise.
*/ */
bool operator()(const Point_2& p1, const Point_2& p2) const bool operator()(const Point_2& p1, const Point_2& p2) const {
{
Kernel kernel; Kernel kernel;
return (kernel.equal_2_object()(p1, p2)); return (kernel.equal_2_object()(p1, p2));
} }
@ -973,8 +934,7 @@ public:
* the left at the line right end. * the left at the line right end.
*/ */
Arr_parameter_space operator()(const X_monotone_curve_2 & xcv, Arr_parameter_space operator()(const X_monotone_curve_2 & xcv,
Arr_curve_end ce) const Arr_curve_end ce) const {
{
CGAL_precondition(! xcv.is_degenerate()); CGAL_precondition(! xcv.is_degenerate());
return (ce == ARR_MIN_END) ? return (ce == ARR_MIN_END) ?
xcv.left_infinite_in_x() : xcv.right_infinite_in_x(); xcv.left_infinite_in_x() : xcv.right_infinite_in_x();
@ -1015,8 +975,7 @@ public:
* right end. * right end.
*/ */
Arr_parameter_space operator()(const X_monotone_curve_2 & xcv, Arr_parameter_space operator()(const X_monotone_curve_2 & xcv,
Arr_curve_end ce) const Arr_curve_end ce) const {
{
CGAL_precondition(! xcv.is_degenerate()); CGAL_precondition(! xcv.is_degenerate());
return (ce == ARR_MIN_END) ? return (ce == ARR_MIN_END) ?
@ -1040,7 +999,7 @@ public:
*/ */
class Compare_x_on_boundary_2 { class Compare_x_on_boundary_2 {
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -1074,8 +1033,7 @@ public:
*/ */
Comparison_result operator()(const Point_2 & p, Comparison_result operator()(const Point_2 & p,
const X_monotone_curve_2 & xcv, const X_monotone_curve_2 & xcv,
Arr_curve_end ) const Arr_curve_end ) const {
{
CGAL_precondition(! xcv.is_degenerate()); CGAL_precondition(! xcv.is_degenerate());
CGAL_precondition(xcv.is_vertical()); CGAL_precondition(xcv.is_vertical());
@ -1105,8 +1063,7 @@ public:
Comparison_result operator()(const X_monotone_curve_2 & xcv1, Comparison_result operator()(const X_monotone_curve_2 & xcv1,
Arr_curve_end /* ce1 */, Arr_curve_end /* ce1 */,
const X_monotone_curve_2 & xcv2, const X_monotone_curve_2 & xcv2,
Arr_curve_end /* ce2 */) const Arr_curve_end /* ce2 */) const {
{
CGAL_precondition(! xcv1.is_degenerate()); CGAL_precondition(! xcv1.is_degenerate());
CGAL_precondition(! xcv2.is_degenerate()); CGAL_precondition(! xcv2.is_degenerate());
CGAL_precondition(xcv1.is_vertical()); CGAL_precondition(xcv1.is_vertical());
@ -1152,8 +1109,7 @@ public:
Comparison_result Comparison_result
operator()(const X_monotone_curve_2& CGAL_precondition_code(xcv1), operator()(const X_monotone_curve_2& CGAL_precondition_code(xcv1),
const X_monotone_curve_2& CGAL_precondition_code(xcv2), const X_monotone_curve_2& CGAL_precondition_code(xcv2),
Arr_curve_end /* ce2 */) const Arr_curve_end /* ce2 */) const {
{
CGAL_precondition(! xcv1.is_degenerate()); CGAL_precondition(! xcv1.is_degenerate());
CGAL_precondition(! xcv2.is_degenerate()); CGAL_precondition(! xcv2.is_degenerate());
CGAL_precondition(xcv1.is_vertical()); CGAL_precondition(xcv1.is_vertical());
@ -1171,7 +1127,7 @@ public:
*/ */
class Compare_y_near_boundary_2 { class Compare_y_near_boundary_2 {
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -1199,8 +1155,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2 & xcv1, Comparison_result operator()(const X_monotone_curve_2 & xcv1,
const X_monotone_curve_2 & xcv2, const X_monotone_curve_2 & xcv2,
Arr_curve_end ce) const Arr_curve_end ce) const {
{
// Make sure both curves are defined at \f$x = -\infty\f$ (or at // Make sure both curves are defined at \f$x = -\infty\f$ (or at
// \f$x = +\infty\f$). // \f$x = +\infty\f$).
CGAL_precondition(! xcv1.is_degenerate()); CGAL_precondition(! xcv1.is_degenerate());
@ -1252,11 +1207,9 @@ public:
* \return The past-the-end iterator. * \return The past-the-end iterator.
*/ */
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const {
{
// Wrap the segment with a variant. // Wrap the segment with a variant.
typedef std::variant<Point_2, X_monotone_curve_2> using Make_x_monotone_result = std::variant<Point_2, X_monotone_curve_2>;
Make_x_monotone_result;
*oi++ = Make_x_monotone_result(cv); *oi++ = Make_x_monotone_result(cv);
return oi; return oi;
} }
@ -1277,8 +1230,7 @@ public:
* \pre `p` lies on `cv` but is not one of its end-points. * \pre `p` lies on `cv` but is not one of its end-points.
*/ */
void operator()(const X_monotone_curve_2& cv, const Point_2& p, void operator()(const X_monotone_curve_2& cv, const Point_2& p,
X_monotone_curve_2& c1, X_monotone_curve_2& c2) const X_monotone_curve_2& c1, X_monotone_curve_2& c2) const {
{
CGAL_precondition(! cv.is_degenerate()); CGAL_precondition(! cv.is_degenerate());
// Make sure that p lies on the interior of the curve. // Make sure that p lies on the interior of the curve.
@ -1306,7 +1258,7 @@ public:
class Intersect_2 { class Intersect_2 {
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -1330,9 +1282,8 @@ public:
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const X_monotone_curve_2& cv1, OutputIterator operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
OutputIterator oi) const OutputIterator oi) const {
{ using Intersection_point = std::pair<Point_2, Multiplicity>;
typedef std::pair<Point_2, Multiplicity> Intersection_point;
CGAL_precondition(! cv1.is_degenerate()); CGAL_precondition(! cv1.is_degenerate());
CGAL_precondition(! cv2.is_degenerate()); CGAL_precondition(! cv2.is_degenerate());
@ -1429,8 +1380,7 @@ public:
* by the same line and share a common endpoint; (false) otherwise. * by the same line and share a common endpoint; (false) otherwise.
*/ */
bool operator()(const X_monotone_curve_2& cv1, bool operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const const X_monotone_curve_2& cv2) const {
{
CGAL_precondition(! cv1.is_degenerate()); CGAL_precondition(! cv1.is_degenerate());
CGAL_precondition(! cv2.is_degenerate()); CGAL_precondition(! cv2.is_degenerate());
@ -1460,7 +1410,7 @@ public:
*/ */
class Merge_2 { class Merge_2 {
protected: protected:
typedef Arr_linear_traits_2<Kernel> Traits; using Traits = Arr_linear_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -1481,8 +1431,7 @@ public:
*/ */
void operator()(const X_monotone_curve_2& cv1, void operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
X_monotone_curve_2& c) const X_monotone_curve_2& c) const {
{
CGAL_precondition(m_traits.are_mergeable_2_object()(cv2, cv1)); CGAL_precondition(m_traits.are_mergeable_2_object()(cv2, cv1));
CGAL_precondition(!cv1.is_degenerate()); CGAL_precondition(!cv1.is_degenerate());
@ -1492,8 +1441,7 @@ public:
// Check which curve extends to the right of the other. // Check which curve extends to the right of the other.
if (cv1.has_right() && cv2.has_left() && if (cv1.has_right() && cv2.has_left() &&
equal(cv1.right(), cv2.left())) equal(cv1.right(), cv2.left())) {
{
// cv2 extends cv1 to the right. // cv2 extends cv1 to the right.
c = cv1; c = cv1;
@ -1519,9 +1467,9 @@ public:
/// \name Functor definitions for the landmarks point-location strategy. /// \name Functor definitions for the landmarks point-location strategy.
//@{ //@{
typedef double Approximate_number_type; using Approximate_number_type = double;
typedef CGAL::Cartesian<Approximate_number_type> Approximate_kernel; using Approximate_kernel = CGAL::Simple_cartesian<Approximate_number_type>;
typedef Approximate_kernel::Point_2 Approximate_point_2; using Approximate_point_2 = Approximate_kernel::Point_2;
class Approximate_2 { class Approximate_2 {
protected: protected:
@ -1545,8 +1493,7 @@ public:
* \return An approximation of `p`'s \f$x\f$-coordinate (if `i` == 0), or an * \return An approximation of `p`'s \f$x\f$-coordinate (if `i` == 0), or an
* approximation of `p`'s \f$y\f$-coordinate (if `i` == 1). * approximation of `p`'s \f$y\f$-coordinate (if `i` == 1).
*/ */
Approximate_number_type operator()(const Point_2& p, int i) const Approximate_number_type operator()(const Point_2& p, int i) const {
{
CGAL_precondition((i == 0) || (i == 1)); CGAL_precondition((i == 0) || (i == 1));
return (i == 0) ? CGAL::to_double(p.x()) : CGAL::to_double(p.y()); return (i == 0) ? CGAL::to_double(p.x()) : CGAL::to_double(p.y());
} }
@ -1566,12 +1513,8 @@ public:
auto max_vertex = m_traits.construct_max_vertex_2_object(); auto max_vertex = m_traits.construct_max_vertex_2_object();
const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv); const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv);
const auto& trg = (l2r) ? max_vertex(xcv) : min_vertex(xcv); const auto& trg = (l2r) ? max_vertex(xcv) : min_vertex(xcv);
auto xs = CGAL::to_double(src.x()); *oi++ = operator()(src);
auto ys = CGAL::to_double(src.y()); *oi++ = operator()(trg);
auto xt = CGAL::to_double(trg.x());
auto yt = CGAL::to_double(trg.y());
*oi++ = Approximate_point_2(xs, ys);
*oi++ = Approximate_point_2(xt, yt);
return oi; return oi;
} }
@ -1580,8 +1523,7 @@ public:
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const X_monotone_curve_2& xcv, double /* error */, OutputIterator operator()(const X_monotone_curve_2& xcv, double /* error */,
OutputIterator oi, const Bbox_2& bbox, OutputIterator oi, const Bbox_2& bbox,
bool l2r = true) const bool l2r = true) const {
{
using Approx_pnt = Approximate_point_2; using Approx_pnt = Approximate_point_2;
using Approx_seg = Approximate_kernel::Segment_2; using Approx_seg = Approximate_kernel::Segment_2;
using Approx_ray = Approximate_kernel::Ray_2; using Approx_ray = Approximate_kernel::Ray_2;
@ -1657,8 +1599,7 @@ public:
* \pre p and q must not be the same. * \pre p and q must not be the same.
* \return A segment connecting `p` and `q`. * \return A segment connecting `p` and `q`.
*/ */
X_monotone_curve_2 operator()(const Point_2& p, const Point_2& q) const X_monotone_curve_2 operator()(const Point_2& p, const Point_2& q) const {
{
Kernel kernel; Kernel kernel;
Segment_2 seg = kernel.construct_segment_2_object()(p, q); Segment_2 seg = kernel.construct_segment_2_object()(p, q);
@ -1675,7 +1616,7 @@ public:
//@{ //@{
//! Functor //! Functor
typedef Construct_x_monotone_curve_2 Construct_curve_2; using Construct_curve_2 = Construct_x_monotone_curve_2;
/*! obtains a `Construct_curve_2` functor object. */ /*! obtains a `Construct_curve_2` functor object. */
Construct_curve_2 construct_curve_2_object() const Construct_curve_2 construct_curve_2_object() const
@ -1688,18 +1629,16 @@ public:
*/ */
template <typename Kernel_> template <typename Kernel_>
class Arr_linear_object_2 : class Arr_linear_object_2 :
public Arr_linear_traits_2<Kernel_>::_Linear_object_cached_2 public Arr_linear_traits_2<Kernel_>::_Linear_object_cached_2 {
{ using Base = typename Arr_linear_traits_2<Kernel_>::_Linear_object_cached_2;
typedef typename Arr_linear_traits_2<Kernel_>::_Linear_object_cached_2
Base;
public: public:
typedef Kernel_ Kernel; using Kernel = Kernel_;
typedef typename Kernel::Point_2 Point_2; using Point_2 = typename Kernel::Point_2;
typedef typename Kernel::Segment_2 Segment_2; using Segment_2 = typename Kernel::Segment_2;
typedef typename Kernel::Ray_2 Ray_2; using Ray_2 = typename Kernel::Ray_2;
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
public: public:
/*! constructs default. /*! constructs default.
@ -1739,8 +1678,7 @@ public:
/*! casts to a segment. /*! casts to a segment.
* \pre The linear object is really a segment. * \pre The linear object is really a segment.
*/ */
Segment_2 segment() const Segment_2 segment() const {
{
CGAL_precondition(is_segment()); CGAL_precondition(is_segment());
Kernel kernel; Kernel kernel;
@ -1756,8 +1694,7 @@ public:
/*! casts to a ray. /*! casts to a ray.
* \pre The linear object is really a ray. * \pre The linear object is really a ray.
*/ */
Ray_2 ray() const Ray_2 ray() const {
{
CGAL_precondition(is_ray()); CGAL_precondition(is_ray());
Kernel kernel; Kernel kernel;
@ -1776,8 +1713,7 @@ public:
/*! casts to a line. /*! casts to a line.
* \pre The linear object is really a line. * \pre The linear object is really a line.
*/ */
Line_2 line() const Line_2 line() const {
{
CGAL_precondition(is_line()); CGAL_precondition(is_line());
return (this->l); return (this->l);
} }
@ -1785,8 +1721,7 @@ public:
/*! obtains the supporting line. /*! obtains the supporting line.
* \pre The object is not a point. * \pre The object is not a point.
*/ */
const Line_2& supporting_line() const const Line_2& supporting_line() const {
{
CGAL_precondition(! this->is_degen); CGAL_precondition(! this->is_degen);
return (this->l); return (this->l);
} }
@ -1794,8 +1729,7 @@ public:
/*! obtains the source point. /*! obtains the source point.
* \pre The object is a point, a segment or a ray. * \pre The object is a point, a segment or a ray.
*/ */
const Point_2& source() const const Point_2& source() const {
{
CGAL_precondition(! is_line()); CGAL_precondition(! is_line());
if (this->is_degen) return (this->ps); // For a point. if (this->is_degen) return (this->ps); // For a point.
@ -1806,16 +1740,14 @@ public:
/*! obtains the target point. /*! obtains the target point.
* \pre The object is a point or a segment. * \pre The object is a point or a segment.
*/ */
const Point_2& target() const const Point_2& target() const {
{
CGAL_precondition(! is_line() && ! is_ray()); CGAL_precondition(! is_line() && ! is_ray());
return (this->pt); return (this->pt);
} }
/*! creates a bounding box for the linear object. /*! creates a bounding box for the linear object.
*/ */
Bbox_2 bbox() const Bbox_2 bbox() const {
{
CGAL_precondition(this->is_segment()); CGAL_precondition(this->is_segment());
Kernel kernel; Kernel kernel;
Segment_2 seg = kernel.construct_segment_2_object()(this->ps, this->pt); Segment_2 seg = kernel.construct_segment_2_object()(this->ps, this->pt);
@ -1834,8 +1766,7 @@ public:
*/ */
template <typename Kernel, typename OutputStream> template <typename Kernel, typename OutputStream>
OutputStream& operator<<(OutputStream& os, OutputStream& operator<<(OutputStream& os,
const Arr_linear_object_2<Kernel>& lobj) const Arr_linear_object_2<Kernel>& lobj) {
{
// Print a letter identifying the object type, then the object itself. // Print a letter identifying the object type, then the object itself.
if (lobj.is_segment()) os << " S " << lobj.segment(); if (lobj.is_segment()) os << " S " << lobj.segment();
else if (lobj.is_ray()) os << " R " << lobj.ray(); else if (lobj.is_ray()) os << " R " << lobj.ray();
@ -1846,8 +1777,7 @@ OutputStream& operator<<(OutputStream& os,
/*! Importer for the segment class used by the traits-class. /*! Importer for the segment class used by the traits-class.
*/ */
template <typename Kernel, typename InputStream> template <typename Kernel, typename InputStream>
InputStream& operator>>(InputStream& is, Arr_linear_object_2<Kernel>& lobj) InputStream& operator>>(InputStream& is, Arr_linear_object_2<Kernel>& lobj) {
{
// Read the object type. // Read the object type.
char c; char c;
do { do {

View File

@ -30,7 +30,7 @@
* functors required by the concept it models. * functors required by the concept it models.
*/ */
#include <CGAL/Cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/Algebraic_structure_traits.h> #include <CGAL/Algebraic_structure_traits.h>
#include <CGAL/number_utils.h> #include <CGAL/number_utils.h>
#include <CGAL/tags.h> #include <CGAL/tags.h>
@ -44,34 +44,28 @@ namespace CGAL {
* A model of the AosBasicTraits_2 concept that handles \f$x\f$-monotone * A model of the AosBasicTraits_2 concept that handles \f$x\f$-monotone
* non-intersecting line segments. * non-intersecting line segments.
*/ */
template <class T_Kernel> template <typename T_Kernel>
class Arr_non_caching_segment_basic_traits_2 : public T_Kernel class Arr_non_caching_segment_basic_traits_2 : public T_Kernel {
{
public: public:
using Kernel = T_Kernel;
typedef T_Kernel Kernel; using FT = typename Kernel::FT;
typedef typename Kernel::FT FT;
private: private:
typedef Algebraic_structure_traits<FT> AST; using AST = Algebraic_structure_traits<FT>;
typedef typename AST::Is_exact FT_is_exact; using FT_is_exact = typename AST::Is_exact;
public: public:
using Has_exact_division = Boolean_tag<FT_is_exact::value>;
typedef Boolean_tag<FT_is_exact::value> Has_exact_division; using Segment_assertions = CGAL::Segment_assertions<Arr_non_caching_segment_basic_traits_2<Kernel>>;
typedef
CGAL::Segment_assertions<Arr_non_caching_segment_basic_traits_2<Kernel> >
Segment_assertions;
// Categories: // Categories:
typedef Tag_true Has_left_category; using Has_left_category = Tag_true;
typedef Tag_false Has_do_intersect_category; using Has_do_intersect_category = Tag_false;
typedef Arr_oblivious_side_tag Left_side_category; using Left_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Bottom_side_category; using Bottom_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Top_side_category; using Top_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Right_side_category; using Right_side_category = Arr_oblivious_side_tag;
/*! constructs default */ /*! constructs default */
Arr_non_caching_segment_basic_traits_2() {} Arr_non_caching_segment_basic_traits_2() {}
@ -80,30 +74,30 @@ public:
//@{ //@{
// Traits types: // Traits types:
typedef typename Kernel::Point_2 Point_2; using Point_2 = typename Kernel::Point_2;
typedef typename Kernel::Segment_2 X_monotone_curve_2; using X_monotone_curve_2 = typename Kernel::Segment_2;
typedef unsigned int Multiplicity; using Multiplicity = std::size_t;
/*! Compare the \f$x\f$-coordinates of two points. */ /*! compares the \f$x\f$-coordinates of two points. */
typedef typename Kernel::Compare_x_2 Compare_x_2; using Compare_x_2 = typename Kernel::Compare_x_2;
/*! Compare two points lexigoraphically; by \f$x\f$, then by \f$y\f$. */ /*! compares two points lexigoraphically; by \f$x\f$, then by \f$y\f$. */
typedef typename Kernel::Compare_xy_2 Compare_xy_2; using Compare_xy_2 = typename Kernel::Compare_xy_2;
/*! Obtain the left endpoint of a given segment. */ /*! obtains the left endpoint of a given segment. */
typedef typename Kernel::Construct_min_vertex_2 Construct_min_vertex_2; using Construct_min_vertex_2 = typename Kernel::Construct_min_vertex_2;
/*! Obtain the right endpoint of a given segment. */ /*! obtains the right endpoint of a given segment. */
typedef typename Kernel::Construct_max_vertex_2 Construct_max_vertex_2; using Construct_max_vertex_2 = typename Kernel::Construct_max_vertex_2;
/*! Check whether a given segment is vertical. */ /*! checks whether a given segment is vertical. */
typedef typename Kernel::Is_vertical_2 Is_vertical_2; using Is_vertical_2 = typename Kernel::Is_vertical_2;
/*! Return the location of a given point with respect to an input segment. */ /*! returns the location of a given point with respect to an input segment. */
typedef typename Kernel::Compare_y_at_x_2 Compare_y_at_x_2; using Compare_y_at_x_2 = typename Kernel::Compare_y_at_x_2;
/*! Check if two segments or if two points are identical. */ /*! checks if two segments or if two points are identical. */
typedef typename Kernel::Equal_2 Equal_2; using Equal_2 = typename Kernel::Equal_2;
//@} //@}
@ -127,8 +121,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2& cv1, Comparison_result operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
const Point_2& CGAL_precondition_code(p)) const const Point_2& CGAL_precondition_code(p)) const {
{
Kernel kernel; Kernel kernel;
// The two segments must be defined at q and also to its left. // The two segments must be defined at q and also to its left.
@ -140,13 +133,13 @@ public:
Compare_xy_2 compare_xy = kernel.compare_xy_2_object(); Compare_xy_2 compare_xy = kernel.compare_xy_2_object();
typename Kernel::Construct_vertex_2 construct_vertex = typename Kernel::Construct_vertex_2 construct_vertex =
kernel.construct_vertex_2_object(); kernel.construct_vertex_2_object();
const Point_2 & source1 = construct_vertex(cv1, 0); const Point_2& source1 = construct_vertex(cv1, 0);
const Point_2 & target1 = construct_vertex(cv1, 1); const Point_2& target1 = construct_vertex(cv1, 1);
const Point_2 & left1 = const Point_2& left1 =
(kernel.less_xy_2_object()(source1, target1)) ? source1 : target1; (kernel.less_xy_2_object()(source1, target1)) ? source1 : target1;
const Point_2 & source2 = construct_vertex(cv2, 0); const Point_2& source2 = construct_vertex(cv2, 0);
const Point_2 & target2 = construct_vertex(cv2, 1); const Point_2& target2 = construct_vertex(cv2, 1);
const Point_2 & left2 = const Point_2& left2 =
(kernel.less_xy_2_object()(source2, target2)) ? source2 : target2; (kernel.less_xy_2_object()(source2, target2)) ? source2 : target2;
); );
@ -181,10 +174,9 @@ public:
* to the right of `p`: `SMALLER`, `LARGER`, or `EQUAL`. * to the right of `p`: `SMALLER`, `LARGER`, or `EQUAL`.
*/ */
Comparison_result operator()(const X_monotone_curve_2 & cv1, Comparison_result operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2 & cv2, const X_monotone_curve_2& cv2,
const Point_2 & CGAL_precondition_code(p)) const const Point_2& CGAL_precondition_code(p)) const {
{
Kernel kernel; Kernel kernel;
// The two segments must be defined at q and also to its right. // The two segments must be defined at q and also to its right.
@ -196,13 +188,13 @@ public:
Compare_xy_2 compare_xy = kernel.compare_xy_2_object(); Compare_xy_2 compare_xy = kernel.compare_xy_2_object();
typename Kernel::Construct_vertex_2 construct_vertex = typename Kernel::Construct_vertex_2 construct_vertex =
kernel.construct_vertex_2_object(); kernel.construct_vertex_2_object();
const Point_2 & source1 = construct_vertex(cv1, 0); const Point_2& source1 = construct_vertex(cv1, 0);
const Point_2 & target1 = construct_vertex(cv1, 1); const Point_2& target1 = construct_vertex(cv1, 1);
const Point_2 & right1 = const Point_2& right1 =
(kernel.less_xy_2_object()(source1, target1)) ? target1 : source1; (kernel.less_xy_2_object()(source1, target1)) ? target1 : source1;
const Point_2 & source2 = construct_vertex(cv2, 0); const Point_2& source2 = construct_vertex(cv2, 0);
const Point_2 & target2 = construct_vertex(cv2, 1); const Point_2& target2 = construct_vertex(cv2, 1);
const Point_2 & right2 = const Point_2& right2 =
(kernel.less_xy_2_object()(source2, target2)) ? target2 : source2; (kernel.less_xy_2_object()(source2, target2)) ? target2 : source2;
); );
@ -222,9 +214,9 @@ public:
/// \name Functor definitions for the landmarks point-location strategy. /// \name Functor definitions for the landmarks point-location strategy.
//@{ //@{
typedef double Approximate_number_type; using Approximate_number_type = double;
typedef CGAL::Cartesian<Approximate_number_type> Approximate_kernel; using Approximate_kernel = CGAL::Simple_cartesian<Approximate_number_type>;
typedef Approximate_kernel::Point_2 Approximate_point_2; using Approximate_point_2 = Approximate_kernel::Point_2;
class Approximate_2 { class Approximate_2 {
protected: protected:
@ -267,12 +259,8 @@ public:
auto max_vertex = m_traits.construct_max_vertex_2_object(); auto max_vertex = m_traits.construct_max_vertex_2_object();
const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv); const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv);
const auto& trg = (l2r) ? max_vertex(xcv) : min_vertex(xcv); const auto& trg = (l2r) ? max_vertex(xcv) : min_vertex(xcv);
auto xs = CGAL::to_double(src.x()); *oi++ = operator()(src);
auto ys = CGAL::to_double(src.y()); *oi++ = operator()(trg);
auto xt = CGAL::to_double(trg.x());
auto yt = CGAL::to_double(trg.y());
*oi++ = Approximate_point_2(xs, ys);
*oi++ = Approximate_point_2(xt, yt);
return oi; return oi;
} }
}; };
@ -280,7 +268,7 @@ public:
/*! obtains an Approximate_2 functor object. */ /*! obtains an Approximate_2 functor object. */
Approximate_2 approximate_2_object () const { return Approximate_2(*this); } Approximate_2 approximate_2_object () const { return Approximate_2(*this); }
typedef typename Kernel::Construct_segment_2 Construct_x_monotone_curve_2; using Construct_x_monotone_curve_2 = typename Kernel::Construct_segment_2;
/*! obtains a `Construct_x_monotone_curve_2` functor object. */ /*! obtains a `Construct_x_monotone_curve_2` functor object. */
Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object () const Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object () const

View File

@ -28,7 +28,7 @@
#include <variant> #include <variant>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/tags.h> #include <CGAL/tags.h>
#include <CGAL/intersections.h> #include <CGAL/intersections.h>
#include <CGAL/Arr_tags.h> #include <CGAL/Arr_tags.h>
@ -52,35 +52,32 @@ class Arr_segment_2;
template <typename Kernel_ = Exact_predicates_exact_constructions_kernel> template <typename Kernel_ = Exact_predicates_exact_constructions_kernel>
class Arr_segment_traits_2 : public Kernel_ { class Arr_segment_traits_2 : public Kernel_ {
friend class Arr_segment_2<Kernel_>; friend class Arr_segment_2<Kernel_>;
public: public:
typedef Kernel_ Kernel; using Kernel = Kernel_;
typedef typename Kernel::FT FT; using FT = typename Kernel::FT;
typedef typename Algebraic_structure_traits<FT>::Is_exact using Has_exact_division = typename Algebraic_structure_traits<FT>::Is_exact;
Has_exact_division;
// Category tags: // Category tags:
typedef Tag_true Has_left_category; using Has_left_category = Tag_true;
typedef Tag_true Has_merge_category; using Has_merge_category = Tag_true;
typedef Tag_false Has_do_intersect_category; using Has_do_intersect_category = Tag_false;
typedef Arr_oblivious_side_tag Left_side_category; using Left_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Bottom_side_category; using Bottom_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Top_side_category; using Top_side_category = Arr_oblivious_side_tag;
typedef Arr_oblivious_side_tag Right_side_category; using Right_side_category = Arr_oblivious_side_tag;
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
typedef CGAL::Segment_assertions<Arr_segment_traits_2<Kernel> > using Segment_assertions = CGAL::Segment_assertions<Arr_segment_traits_2<Kernel>>;
Segment_assertions;
/*! \class Representation of a segment with cached data. /*! \class Representation of a segment with cached data.
*/ */
class _Segment_cached_2 { class _Segment_cached_2 {
public: public:
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
typedef typename Kernel::Segment_2 Segment_2; using Segment_2 = typename Kernel::Segment_2;
typedef typename Kernel::Point_2 Point_2; using Point_2 = typename Kernel::Point_2;
protected: protected:
mutable Line_2 m_l; // the line that supports the segment. mutable Line_2 m_l; // the line that supports the segment.
@ -228,10 +225,10 @@ public:
public: public:
// Traits objects // Traits objects
typedef typename Kernel::Point_2 Point_2; using Point_2 = typename Kernel::Point_2;
typedef Arr_segment_2<Kernel> X_monotone_curve_2; using X_monotone_curve_2 = Arr_segment_2<Kernel>;
typedef Arr_segment_2<Kernel> Curve_2; using Curve_2 = Arr_segment_2<Kernel>;
typedef unsigned int Multiplicity; using Multiplicity = std::size_t;
public: public:
/*! constructs default. */ /*! constructs default. */
@ -242,7 +239,7 @@ public:
class Compare_x_2 { class Compare_x_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
//! The traits (in case it has state). //! The traits (in case it has state).
const Traits& m_traits; const Traits& m_traits;
@ -262,8 +259,7 @@ public:
* `SMALLER` if x(p1) < x(p2); * `SMALLER` if x(p1) < x(p2);
* `EQUAL` if x(p1) = x(p2). * `EQUAL` if x(p1) = x(p2).
*/ */
Comparison_result operator()(const Point_2& p1, const Point_2& p2) const Comparison_result operator()(const Point_2& p1, const Point_2& p2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
return (kernel.compare_x_2_object()(p1, p2)); return (kernel.compare_x_2_object()(p1, p2));
} }
@ -274,7 +270,7 @@ public:
class Compare_xy_2 { class Compare_xy_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -294,8 +290,7 @@ public:
* SMALLER if x(p1) < x(p2), or if x(p1) = x(p2) and y(p1) < y(p2); * SMALLER if x(p1) < x(p2), or if x(p1) = x(p2) and y(p1) < y(p2);
* EQUAL if the two points are equal. * EQUAL if the two points are equal.
*/ */
Comparison_result operator()(const Point_2& p1, const Point_2& p2) const Comparison_result operator()(const Point_2& p1, const Point_2& p2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
return (kernel.compare_xy_2_object()(p1, p2)); return (kernel.compare_xy_2_object()(p1, p2));
} }
@ -347,7 +342,7 @@ public:
class Compare_y_at_x_2 { class Compare_y_at_x_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -369,8 +364,7 @@ public:
* `EQUAL` if `p` lies on the curve. * `EQUAL` if `p` lies on the curve.
*/ */
Comparison_result operator()(const Point_2& p, Comparison_result operator()(const Point_2& p,
const X_monotone_curve_2& cv) const const X_monotone_curve_2& cv) const {
{
CGAL_precondition(m_traits.is_in_x_range_2_object()(cv, p)); CGAL_precondition(m_traits.is_in_x_range_2_object()(cv, p));
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
@ -396,7 +390,7 @@ public:
class Compare_y_at_x_left_2 { class Compare_y_at_x_left_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -421,8 +415,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2& cv1, Comparison_result operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
const Point_2& CGAL_assertion_code(p)) const const Point_2& CGAL_assertion_code(p)) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
// Make sure that p lies on both curves, and that both are defined to its // Make sure that p lies on both curves, and that both are defined to its
@ -450,7 +443,7 @@ public:
class Compare_y_at_x_right_2 { class Compare_y_at_x_right_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -475,8 +468,7 @@ public:
*/ */
Comparison_result operator()(const X_monotone_curve_2& cv1, Comparison_result operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
const Point_2& CGAL_assertion_code(p)) const const Point_2& CGAL_assertion_code(p)) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
// Make sure that p lies on both curves, and that both are defined to its // Make sure that p lies on both curves, and that both are defined to its
@ -502,7 +494,7 @@ public:
class Equal_2 { class Equal_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -522,8 +514,7 @@ public:
* \return (true) if the two curves are the same; (false) otherwise. * \return (true) if the two curves are the same; (false) otherwise.
*/ */
bool operator()(const X_monotone_curve_2& cv1, bool operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const const X_monotone_curve_2& cv2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
typename Kernel::Equal_2 equal = kernel.equal_2_object(); typename Kernel::Equal_2 equal = kernel.equal_2_object();
@ -536,8 +527,7 @@ public:
* \param p2 the second point. * \param p2 the second point.
* \return (true) if the two point are the same; (false) otherwise. * \return (true) if the two point are the same; (false) otherwise.
*/ */
bool operator()(const Point_2& p1, const Point_2& p2) const bool operator()(const Point_2& p1, const Point_2& p2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
return (kernel.equal_2_object()(p1, p2)); return (kernel.equal_2_object()(p1, p2));
} }
@ -566,11 +556,9 @@ public:
* \return the past-the-end output iterator. * \return the past-the-end output iterator.
*/ */
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const {
{
// Wrap the segment with a variant. // Wrap the segment with a variant.
typedef std::variant<Point_2, X_monotone_curve_2> using Make_x_monotone_result = std::variant<Point_2, X_monotone_curve_2>;
Make_x_monotone_result;
*oi++ = Make_x_monotone_result(cv); *oi++ = Make_x_monotone_result(cv);
return oi; return oi;
} }
@ -582,7 +570,7 @@ public:
class Split_2 { class Split_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -595,7 +583,7 @@ public:
friend class Arr_segment_traits_2<Kernel>; friend class Arr_segment_traits_2<Kernel>;
public: public:
/*! split a given \f$x\f$-monotone curve at a given point into two /*! splits a given \f$x\f$-monotone curve at a given point into two
* sub-curves. * sub-curves.
* \param cv the curve to split * \param cv the curve to split
* \param p the split point. * \param p the split point.
@ -604,8 +592,7 @@ public:
* \pre `p` lies on cv but is not one of its endpoints. * \pre `p` lies on cv but is not one of its endpoints.
*/ */
void operator()(const X_monotone_curve_2& cv, const Point_2& p, void operator()(const X_monotone_curve_2& cv, const Point_2& p,
X_monotone_curve_2& c1, X_monotone_curve_2& c2) const X_monotone_curve_2& c1, X_monotone_curve_2& c2) const {
{
// Make sure that p lies on the interior of the curve. // Make sure that p lies on the interior of the curve.
CGAL_precondition_code(const Kernel& kernel = m_traits; CGAL_precondition_code(const Kernel& kernel = m_traits;
auto compare_xy = kernel.compare_xy_2_object()); auto compare_xy = kernel.compare_xy_2_object());
@ -628,7 +615,7 @@ public:
class Intersect_2 { class Intersect_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -644,8 +631,7 @@ public:
// this point, we already know which point is left / right for // this point, we already know which point is left / right for
// both segments // both segments
bool do_intersect(const Point_2& A1, const Point_2& A2, bool do_intersect(const Point_2& A1, const Point_2& A2,
const Point_2& B1, const Point_2& B2) const const Point_2& B1, const Point_2& B2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
auto compare_xy = kernel.compare_xy_2_object(); auto compare_xy = kernel.compare_xy_2_object();
namespace interx = CGAL::Intersections::internal; namespace interx = CGAL::Intersections::internal;
@ -686,8 +672,7 @@ public:
/*! determines whether the bounding boxes of two segments overlap /*! determines whether the bounding boxes of two segments overlap
*/ */
bool do_bboxes_overlap(const X_monotone_curve_2& cv1, bool do_bboxes_overlap(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const const X_monotone_curve_2& cv2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
auto construct_bbox = kernel.construct_bbox_2_object(); auto construct_bbox = kernel.construct_bbox_2_object();
auto bbox1 = construct_bbox(cv1.source()) + construct_bbox(cv1.target()); auto bbox1 = construct_bbox(cv1.source()) + construct_bbox(cv1.target());
@ -707,9 +692,8 @@ public:
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator operator()(const X_monotone_curve_2& cv1, OutputIterator operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
OutputIterator oi) const OutputIterator oi) const {
{ using Intersection_point = std::pair<Point_2, Multiplicity>;
typedef std::pair<Point_2, Multiplicity> Intersection_point;
// Early ending with Bbox overlapping test // Early ending with Bbox overlapping test
if (! do_bboxes_overlap(cv1, cv2)) return oi; if (! do_bboxes_overlap(cv1, cv2)) return oi;
@ -787,7 +771,7 @@ public:
class Are_mergeable_2 { class Are_mergeable_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -808,8 +792,7 @@ public:
* \pre `cv1` and `cv2` share a common endpoint. * \pre `cv1` and `cv2` share a common endpoint.
*/ */
bool operator()(const X_monotone_curve_2& cv1, bool operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2) const const X_monotone_curve_2& cv2) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
typename Kernel::Equal_2 equal = kernel.equal_2_object(); typename Kernel::Equal_2 equal = kernel.equal_2_object();
if (! equal(cv1.right(), cv2.left()) && if (! equal(cv1.right(), cv2.left()) &&
@ -832,7 +815,7 @@ public:
*/ */
class Merge_2 { class Merge_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state) */ /*! The traits (in case it has state) */
const Traits& m_traits; const Traits& m_traits;
@ -853,14 +836,13 @@ public:
*/ */
void operator()(const X_monotone_curve_2& cv1, void operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2, const X_monotone_curve_2& cv2,
X_monotone_curve_2& c) const X_monotone_curve_2& c) const {
{
CGAL_precondition(m_traits.are_mergeable_2_object()(cv1, cv2)); CGAL_precondition(m_traits.are_mergeable_2_object()(cv1, cv2));
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
auto equal = kernel.equal_2_object(); auto equal = kernel.equal_2_object();
// Check which curve extends to the right of the other. // checks which curve extends to the right of the other.
if (equal(cv1.right(), cv2.left())) { if (equal(cv1.right(), cv2.left())) {
// cv2 extends cv1 to the right. // cv2 extends cv1 to the right.
c = cv1; c = cv1;
@ -882,9 +864,9 @@ public:
/// \name Functor definitions for the landmarks point-location strategy. /// \name Functor definitions for the landmarks point-location strategy.
//@{ //@{
typedef double Approximate_number_type; using Approximate_number_type = double;
typedef CGAL::Cartesian<Approximate_number_type> Approximate_kernel; using Approximate_kernel = CGAL::Simple_cartesian<Approximate_number_type>;
typedef Approximate_kernel::Point_2 Approximate_point_2; using Approximate_point_2 = Approximate_kernel::Point_2;
class Approximate_2 { class Approximate_2 {
protected: protected:
@ -927,12 +909,8 @@ public:
auto max_vertex = m_traits.construct_max_vertex_2_object(); auto max_vertex = m_traits.construct_max_vertex_2_object();
const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv); const auto& src = (l2r) ? min_vertex(xcv) : max_vertex(xcv);
const auto& trg = (l2r) ? max_vertex(xcv) : min_vertex(xcv); const auto& trg = (l2r) ? max_vertex(xcv) : min_vertex(xcv);
auto xs = CGAL::to_double(src.x()); *oi++ = operator()(src);
auto ys = CGAL::to_double(src.y()); *oi++ = operator()(trg);
auto xt = CGAL::to_double(trg.x());
auto yt = CGAL::to_double(trg.y());
*oi++ = Approximate_point_2(xs, ys);
*oi++ = Approximate_point_2(xt, yt);
return oi; return oi;
} }
}; };
@ -943,7 +921,7 @@ public:
//! Functor //! Functor
class Construct_x_monotone_curve_2 { class Construct_x_monotone_curve_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
//! The traits (in case it has state). //! The traits (in case it has state).
const Traits& m_traits; const Traits& m_traits;
@ -956,7 +934,7 @@ public:
friend class Arr_segment_traits_2<Kernel>; friend class Arr_segment_traits_2<Kernel>;
public: public:
typedef typename Kernel::Segment_2 Segment_2; using Segment_2 = typename Kernel::Segment_2;
/*! obtains an \f$x\f$-monotone curve connecting two given endpoints. /*! obtains an \f$x\f$-monotone curve connecting two given endpoints.
* \param source the first point. * \param source the first point.
@ -965,8 +943,7 @@ public:
* \return a segment connecting `source` and `target`. * \return a segment connecting `source` and `target`.
*/ */
X_monotone_curve_2 operator()(const Point_2& source, X_monotone_curve_2 operator()(const Point_2& source,
const Point_2& target) const const Point_2& target) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
auto line = kernel.construct_line_2_object()(source, target); auto line = kernel.construct_line_2_object()(source, target);
Comparison_result res = kernel.compare_xy_2_object()(source, target); Comparison_result res = kernel.compare_xy_2_object()(source, target);
@ -985,8 +962,7 @@ public:
* \pre the segment is not degenerate. * \pre the segment is not degenerate.
* \return a segment that is the same as `seg`.. * \return a segment that is the same as `seg`..
*/ */
X_monotone_curve_2 operator()(const Segment_2& seg) const X_monotone_curve_2 operator()(const Segment_2& seg) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
auto line = kernel.construct_line_2_object()(seg); auto line = kernel.construct_line_2_object()(seg);
auto vertex_ctr = kernel.construct_vertex_2_object(); auto vertex_ctr = kernel.construct_vertex_2_object();
@ -1011,8 +987,7 @@ public:
*/ */
X_monotone_curve_2 operator()(const Line_2& line, X_monotone_curve_2 operator()(const Line_2& line,
const Point_2& source, const Point_2& source,
const Point_2& target) const const Point_2& target) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
CGAL_precondition CGAL_precondition
(Segment_assertions::_assert_is_point_on(source, line, (Segment_assertions::_assert_is_point_on(source, line,
@ -1039,7 +1014,7 @@ public:
//@{ //@{
//! Functor //! Functor
typedef Construct_x_monotone_curve_2 Construct_curve_2; using Construct_curve_2 = Construct_x_monotone_curve_2;
/*! obtains a `Construct_curve_2` functor object. */ /*! obtains a `Construct_curve_2` functor object. */
Construct_curve_2 construct_curve_2_object() const Construct_curve_2 construct_curve_2_object() const
@ -1051,7 +1026,7 @@ public:
class Trim_2 { class Trim_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
/*! The traits (in case it has state). */ /*! The traits (in case it has state). */
const Traits& m_traits; const Traits& m_traits;
@ -1074,8 +1049,7 @@ public:
public: public:
X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv, X_monotone_curve_2 operator()(const X_monotone_curve_2& xcv,
const Point_2& src, const Point_2& src,
const Point_2& tgt)const const Point_2& tgt) const {
{
CGAL_precondition_code(Equal_2 equal = m_traits.equal_2_object()); CGAL_precondition_code(Equal_2 equal = m_traits.equal_2_object());
CGAL_precondition_code(Compare_y_at_x_2 compare_y_at_x = CGAL_precondition_code(Compare_y_at_x_2 compare_y_at_x =
m_traits.compare_y_at_x_2_object()); m_traits.compare_y_at_x_2_object());
@ -1119,7 +1093,7 @@ public:
class Construct_opposite_2 { class Construct_opposite_2 {
public: public:
/*! Construct an opposite \f$x\f$-monotone (with swapped source and target). /*! constructs an opposite \f$x\f$-monotone (with swapped source and target).
* \param cv the curve. * \param cv the curve.
* \return the opposite curve. * \return the opposite curve.
*/ */
@ -1137,12 +1111,12 @@ public:
class Is_in_x_range_2 { class Is_in_x_range_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
//! The traits (in case it has state). //! The traits (in case it has state).
const Traits& m_traits; const Traits& m_traits;
/*! Construct /*! constructs
* \param traits the traits (in case it has state) * \param traits the traits (in case it has state)
*/ */
Is_in_x_range_2(const Traits& traits) : m_traits(traits) {} Is_in_x_range_2(const Traits& traits) : m_traits(traits) {}
@ -1156,8 +1130,7 @@ public:
* \param p the point. * \param p the point.
* \return true if p is in the \f$x\f$-range of cv; false otherwise. * \return true if p is in the \f$x\f$-range of cv; false otherwise.
*/ */
bool operator()(const X_monotone_curve_2& cv, const Point_2& p) const bool operator()(const X_monotone_curve_2& cv, const Point_2& p) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
auto compare_x = kernel.compare_x_2_object(); auto compare_x = kernel.compare_x_2_object();
Comparison_result res1 = compare_x(p, cv.left()); Comparison_result res1 = compare_x(p, cv.left());
@ -1176,7 +1149,7 @@ public:
class Is_in_y_range_2 { class Is_in_y_range_2 {
protected: protected:
typedef Arr_segment_traits_2<Kernel> Traits; using Traits = Arr_segment_traits_2<Kernel>;
//! The traits (in case it has state). //! The traits (in case it has state).
const Traits& m_traits; const Traits& m_traits;
@ -1195,8 +1168,7 @@ public:
* \param p the point. * \param p the point.
* \return true if p is in the \f$y\f$-range of cv; false otherwise. * \return true if p is in the \f$y\f$-range of cv; false otherwise.
*/ */
bool operator()(const X_monotone_curve_2& cv, const Point_2& p) const bool operator()(const X_monotone_curve_2& cv, const Point_2& p) const {
{
const Kernel& kernel = m_traits; const Kernel& kernel = m_traits;
auto compare_y = kernel.compare_y_2_object(); auto compare_y = kernel.compare_y_2_object();
Comparison_result res1 = compare_y(p, cv.left()); Comparison_result res1 = compare_y(p, cv.left());
@ -1232,8 +1204,7 @@ template <typename Kernel>
Arr_segment_traits_2<Kernel>:: Arr_segment_traits_2<Kernel>::
_Segment_cached_2::_Segment_cached_2(const Segment_2& seg) : _Segment_cached_2::_Segment_cached_2(const Segment_2& seg) :
m_is_vert(false), m_is_vert(false),
m_is_computed(false) m_is_computed(false) {
{
Kernel kernel; Kernel kernel;
auto vertex_ctr = kernel.construct_vertex_2_object(); auto vertex_ctr = kernel.construct_vertex_2_object();
@ -1255,8 +1226,7 @@ _Segment_cached_2::_Segment_cached_2(const Point_2& source,
m_ps(source), m_ps(source),
m_pt(target), m_pt(target),
m_is_vert(false), m_is_vert(false),
m_is_computed(false) m_is_computed(false) {
{
Kernel kernel; Kernel kernel;
Comparison_result res = kernel.compare_xy_2_object()(m_ps, m_pt); Comparison_result res = kernel.compare_xy_2_object()(m_ps, m_pt);
@ -1274,8 +1244,7 @@ _Segment_cached_2::_Segment_cached_2(const Line_2& line,
const Point_2& target) : const Point_2& target) :
m_l(line), m_l(line),
m_ps(source), m_ps(source),
m_pt(target) m_pt(target) {
{
Kernel kernel; Kernel kernel;
CGAL_precondition CGAL_precondition
@ -1312,8 +1281,7 @@ _Segment_cached_2(const Line_2& line,
//! \brief assigns. //! \brief assigns.
template <typename Kernel> template <typename Kernel>
const typename Arr_segment_traits_2<Kernel>::_Segment_cached_2& const typename Arr_segment_traits_2<Kernel>::_Segment_cached_2&
Arr_segment_traits_2<Kernel>::_Segment_cached_2::operator=(const Segment_2& seg) Arr_segment_traits_2<Kernel>::_Segment_cached_2::operator=(const Segment_2& seg) {
{
Kernel kernel; Kernel kernel;
auto vertex_ctr = kernel.construct_vertex_2_object(); auto vertex_ctr = kernel.construct_vertex_2_object();
@ -1338,8 +1306,7 @@ Arr_segment_traits_2<Kernel>::_Segment_cached_2::operator=(const Segment_2& seg)
//! \brief obtains the supporting line. //! \brief obtains the supporting line.
template <typename Kernel> template <typename Kernel>
const typename Kernel::Line_2& const typename Kernel::Line_2&
Arr_segment_traits_2<Kernel>::_Segment_cached_2::line() const Arr_segment_traits_2<Kernel>::_Segment_cached_2::line() const {
{
if (!m_is_computed) { if (!m_is_computed) {
Kernel kernel; Kernel kernel;
m_l = kernel.construct_line_2_object()(m_ps, m_pt); m_l = kernel.construct_line_2_object()(m_ps, m_pt);
@ -1351,8 +1318,7 @@ Arr_segment_traits_2<Kernel>::_Segment_cached_2::line() const
//! \brief determines whether the curve is vertical. //! \brief determines whether the curve is vertical.
template <typename Kernel> template <typename Kernel>
bool Arr_segment_traits_2<Kernel>::_Segment_cached_2::is_vertical() const bool Arr_segment_traits_2<Kernel>::_Segment_cached_2::is_vertical() const {
{
// Force computation of line is orientation is still unknown // Force computation of line is orientation is still unknown
if (! m_is_computed) line(); if (! m_is_computed) line();
CGAL_precondition(!m_is_degen); CGAL_precondition(!m_is_degen);
@ -1397,8 +1363,7 @@ Arr_segment_traits_2<Kernel>::_Segment_cached_2::right() const
//! \brief sets the (lexicographically) left endpoint. //! \brief sets the (lexicographically) left endpoint.
template <typename Kernel> template <typename Kernel>
void Arr_segment_traits_2<Kernel>::_Segment_cached_2::set_left(const Point_2& p) void Arr_segment_traits_2<Kernel>::_Segment_cached_2::set_left(const Point_2& p) {
{
CGAL_precondition(! m_is_degen); CGAL_precondition(! m_is_degen);
CGAL_precondition_code(Kernel kernel); CGAL_precondition_code(Kernel kernel);
CGAL_precondition CGAL_precondition
@ -1411,8 +1376,7 @@ void Arr_segment_traits_2<Kernel>::_Segment_cached_2::set_left(const Point_2& p)
//! \brief sets the (lexicographically) right endpoint. //! \brief sets the (lexicographically) right endpoint.
template <typename Kernel> template <typename Kernel>
void Arr_segment_traits_2<Kernel>::_Segment_cached_2::set_right(const Point_2& p) void Arr_segment_traits_2<Kernel>::_Segment_cached_2::set_right(const Point_2& p) {
{
CGAL_precondition(! m_is_degen); CGAL_precondition(! m_is_degen);
CGAL_precondition_code(Kernel kernel); CGAL_precondition_code(Kernel kernel);
CGAL_precondition CGAL_precondition
@ -1428,8 +1392,7 @@ void Arr_segment_traits_2<Kernel>::_Segment_cached_2::set_right(const Point_2& p
*/ */
template <typename Kernel> template <typename Kernel>
bool Arr_segment_traits_2<Kernel>::_Segment_cached_2:: bool Arr_segment_traits_2<Kernel>::_Segment_cached_2::
is_in_x_range(const Point_2& p) const is_in_x_range(const Point_2& p) const {
{
Kernel kernel; Kernel kernel;
typename Kernel::Compare_x_2 compare_x = kernel.compare_x_2_object(); typename Kernel::Compare_x_2 compare_x = kernel.compare_x_2_object();
const Comparison_result res1 = compare_x(p, left()); const Comparison_result res1 = compare_x(p, left());
@ -1446,8 +1409,7 @@ is_in_x_range(const Point_2& p) const
*/ */
template <typename Kernel> template <typename Kernel>
bool Arr_segment_traits_2<Kernel>::_Segment_cached_2:: bool Arr_segment_traits_2<Kernel>::_Segment_cached_2::
is_in_y_range(const Point_2& p) const is_in_y_range(const Point_2& p) const {
{
Kernel kernel; Kernel kernel;
typename Kernel::Compare_y_2 compare_y = kernel.compare_y_2_object(); typename Kernel::Compare_y_2 compare_y = kernel.compare_y_2_object();
const Comparison_result res1 = compare_y(p, left()); const Comparison_result res1 = compare_y(p, left());
@ -1464,31 +1426,31 @@ is_in_y_range(const Point_2& p) const
*/ */
template <typename Kernel_> template <typename Kernel_>
class Arr_segment_2 : public Arr_segment_traits_2<Kernel_>::_Segment_cached_2 { class Arr_segment_2 : public Arr_segment_traits_2<Kernel_>::_Segment_cached_2 {
typedef Kernel_ Kernel; using Kernel = Kernel_;
typedef typename Arr_segment_traits_2<Kernel>::_Segment_cached_2 Base; using Base = typename Arr_segment_traits_2<Kernel>::_Segment_cached_2;
typedef typename Kernel::Segment_2 Segment_2; using Segment_2 = typename Kernel::Segment_2;
typedef typename Kernel::Point_2 Point_2; using Point_2 = typename Kernel::Point_2;
typedef typename Kernel::Line_2 Line_2; using Line_2 = typename Kernel::Line_2;
public: public:
/*! Construct default. */ /*! constructs default. */
Arr_segment_2(); Arr_segment_2();
/*! Construct a segment from a "kernel" segment. /*! constructs a segment from a "kernel" segment.
* \param seg the segment. * \param seg the segment.
* \pre the segment is not degenerate. * \pre the segment is not degenerate.
*/ */
Arr_segment_2(const Segment_2& seg); Arr_segment_2(const Segment_2& seg);
/*! Construct a segment from two endpoints. /*! constructs a segment from two endpoints.
* \param source the source point. * \param source the source point.
* \param target the target point. * \param target the target point.
* \pre `source` and `target` are not equal. * \pre `source` and `target` are not equal.
*/ */
Arr_segment_2(const Point_2& source, const Point_2& target); Arr_segment_2(const Point_2& source, const Point_2& target);
/*! Construct a segment from a line and two endpoints. /*! constructs a segment from a line and two endpoints.
* \param line the supporting line. * \param line the supporting line.
* \param source the source point. * \param source the source point.
* \param target the target point. * \param target the target point.
@ -1498,7 +1460,7 @@ public:
Arr_segment_2(const Line_2& line, Arr_segment_2(const Line_2& line,
const Point_2& source, const Point_2& target); const Point_2& source, const Point_2& target);
/*! Construct a segment from all fields. /*! constructs a segment from all fields.
* \param line the supporting line. * \param line the supporting line.
* \param source the source point. * \param source the source point.
* \param target the target point. * \param target the target point.
@ -1510,11 +1472,11 @@ public:
const Point_2& source, const Point_2& target, const Point_2& source, const Point_2& target,
bool is_directed_right, bool is_vert, bool is_degen); bool is_directed_right, bool is_vert, bool is_degen);
/*! Cast to a segment. /*! casts to a segment.
*/ */
operator Segment_2() const; operator Segment_2() const;
/*! Flip the segment (swap its source and target). /*! flips the segment (swap its source and target).
*/ */
Arr_segment_2 flip() const; Arr_segment_2 flip() const;
@ -1558,8 +1520,7 @@ Arr_segment_2<Kernel>::Arr_segment_2(const Line_2& line,
//! \brief casts to a segment. //! \brief casts to a segment.
template <typename Kernel> template <typename Kernel>
Arr_segment_2<Kernel>::operator typename Kernel::Segment_2() const Arr_segment_2<Kernel>::operator typename Kernel::Segment_2() const {
{
Kernel kernel; Kernel kernel;
auto seg_ctr = kernel.construct_segment_2_object(); auto seg_ctr = kernel.construct_segment_2_object();
return seg_ctr(this->source(), this->target()); return seg_ctr(this->source(), this->target());
@ -1567,8 +1528,7 @@ Arr_segment_2<Kernel>::operator typename Kernel::Segment_2() const
//! \brief flips the segment (swap its source and target). //! \brief flips the segment (swap its source and target).
template <typename Kernel> template <typename Kernel>
Arr_segment_2<Kernel> Arr_segment_2<Kernel>::flip() const Arr_segment_2<Kernel> Arr_segment_2<Kernel>::flip() const {
{
return Arr_segment_2(this->line(), this->target(), this->source(), return Arr_segment_2(this->line(), this->target(), this->source(),
! (this->is_directed_right()), this->is_vertical(), ! (this->is_directed_right()), this->is_vertical(),
this->is_degenerate()); this->is_degenerate());
@ -1586,8 +1546,7 @@ Bbox_2 Arr_segment_2<Kernel>::bbox() const
/*! Exporter for the segment class used by the traits-class. /*! Exporter for the segment class used by the traits-class.
*/ */
template <typename Kernel, typename OutputStream> template <typename Kernel, typename OutputStream>
OutputStream& operator<<(OutputStream& os, const Arr_segment_2<Kernel>& seg) OutputStream& operator<<(OutputStream& os, const Arr_segment_2<Kernel>& seg) {
{
os << static_cast<typename Kernel::Segment_2>(seg); os << static_cast<typename Kernel::Segment_2>(seg);
return (os); return (os);
} }
@ -1595,8 +1554,7 @@ OutputStream& operator<<(OutputStream& os, const Arr_segment_2<Kernel>& seg)
/*! Importer for the segment class used by the traits-class. /*! Importer for the segment class used by the traits-class.
*/ */
template <typename Kernel, typename InputStream> template <typename Kernel, typename InputStream>
InputStream& operator>>(InputStream& is, Arr_segment_2<Kernel>& seg) InputStream& operator>>(InputStream& is, Arr_segment_2<Kernel>& seg) {
{
typename Kernel::Segment_2 kernel_seg; typename Kernel::Segment_2 kernel_seg;
is >> kernel_seg; is >> kernel_seg;
seg = kernel_seg; seg = kernel_seg;

View File

@ -588,7 +588,7 @@ private:
#ifdef CGAL_USE_BASIC_VIEWER #ifdef CGAL_USE_BASIC_VIEWER
//! //!
void draw_unimplemented() { inline void draw_unimplemented() {
CGAL_error_msg("Geometry traits type of arrangement is required to support approximation of Point_2 and " CGAL_error_msg("Geometry traits type of arrangement is required to support approximation of Point_2 and "
"X_monotone_curve_2. Traits on curved surfaces needs additional support for parameterization."); "X_monotone_curve_2. Traits on curved surfaces needs additional support for parameterization.");
} }