From 4e48b0b9847b95c88e200290ed80d8e4066682b2 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 15:10:16 +0200 Subject: [PATCH 01/11] Fixed definition of Nop_decomposition (added Container parameter) --- .../include/CGAL/minkowski_sum_2.h | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h b/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h index 96c4045feb5..7a782893e30 100644 --- a/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h +++ b/Minkowski_sum_2/include/CGAL/minkowski_sum_2.h @@ -761,10 +761,10 @@ minkowski_sum_by_decomposition_2 const Decomposition_& decomp, const Gps_segment_traits_2& traits) { - typedef Kernel_ Kernel; - typedef Container_ Container; - typedef Decomposition_ Decomposition; - typedef Polygon_nop_decomposition_2 Nop_decomposition; + typedef Kernel_ Kernel; + typedef Container_ Container; + typedef Decomposition_ Decomposition; + typedef Polygon_nop_decomposition_2 Nop_decomposition; if (pgn1.is_convex()) { Nop_decomposition decomp_nop; @@ -839,11 +839,11 @@ minkowski_sum_by_decomposition_2 const WithHolesDecomposition_& decomp_with_holes, const Gps_segment_traits_2& traits) { - typedef Kernel_ Kernel; - typedef Container_ Container; - typedef NoHolesDecomposition_ No_holes_decomposition; - typedef WithHolesDecomposition_ With_holes_decomposition; - typedef Polygon_nop_decomposition_2 Nop_decomposition; + typedef Kernel_ Kernel; + typedef Container_ Container; + typedef NoHolesDecomposition_ No_holes_decomposition; + typedef WithHolesDecomposition_ With_holes_decomposition; + typedef Polygon_nop_decomposition_2 Nop_decomposition; Hole_filter_2 hole_filter; Polygon_with_holes_2 filtered_pgn1; @@ -982,11 +982,11 @@ minkowski_sum_by_decomposition_2 const WithHolesDecomposition_& decomp_with_holes, const Gps_segment_traits_2& traits) { - typedef Kernel_ Kernel; - typedef Container_ Container; - typedef NoHolesDecomposition_ No_holes_decomposition; - typedef WithHolesDecomposition_ With_holes_decomposition; - typedef Polygon_nop_decomposition_2 Nop_decomposition; + typedef Kernel_ Kernel; + typedef Container_ Container; + typedef NoHolesDecomposition_ No_holes_decomposition; + typedef WithHolesDecomposition_ With_holes_decomposition; + typedef Polygon_nop_decomposition_2 Nop_decomposition; Hole_filter_2 hole_filter; Polygon_with_holes_2 filtered_pgn2; From 46529b376cd612b09833f7a6f61ae9a05cf74d2e Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 15:18:55 +0200 Subject: [PATCH 02/11] Fixed name construct_is_unbounded_object() => is_unbounded_object() --- .../Concepts/GeneralPolygonSetTraits_2.h | 3 +-- Boolean_set_operations_2/include/CGAL/Gps_traits_2.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h b/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h index 83fe7a4acd1..1009ff95fbd 100644 --- a/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h +++ b/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h @@ -141,9 +141,8 @@ Construct_holes construct_holes_object() const; /*! returns a functor that determines if the polygon with holes is unbounded */ -Is_unbounded construct_is_unbounded_object(); +Is_unbounded is_unbounded_object(); /// @} }; /* end GeneralPolygonSetTraits_2 */ - diff --git a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h index 25158f34d22..a402e5c7f52 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h @@ -163,7 +163,7 @@ public: { return pol_wh.is_unbounded(); } }; - Is_unbounded construct_is_unbounded_object() const { return Is_unbounded(); } + Is_unbounded is_unbounded_object() const { return Is_unbounded(); } // Equality operator class Equal_2 { From c3128da566135d0a6da7e8deb359c228e9a3b03a Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 15:29:23 +0200 Subject: [PATCH 03/11] Replaced General_polygon_... => Polygon, Construct_general_polygon_... => Construct_polygon --- .../Concepts/GeneralPolygonSetTraits_2.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h b/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h index 1009ff95fbd..86f4cc299da 100644 --- a/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h +++ b/Boolean_set_operations_2/doc/Boolean_set_operations_2/Concepts/GeneralPolygonSetTraits_2.h @@ -61,30 +61,30 @@ typedef unspecified_type Construct_polygon_2; /*! a functor that constructs a general polygon with holes from a general polygon and, optionally, a range of holes. It uses the operator -`void operator() (const General_polygon_2& pgn_boundary)` or +`void operator() (const Polygon_2& pgn_boundary)` or -`void operator() (const General_polygon_2& pgn_boundary, HolesInputIterator h_begin, HolesInputIterator h_end)` parameterized by the `HolesInputIterator` type. +`void operator() (const Polygon_2& pgn_boundary, HolesInputIterator h_begin, HolesInputIterator h_end)` parameterized by the `HolesInputIterator` type. */ -typedef unspecified_type Construct_general_polygon_with_holes_2; +typedef unspecified_type Construct_polygon_with_holes_2; /*! A functor for constructing the outer boundary of a polygon with holes. It uses the operator -`General_polygon_2 operator()(const General_polygon_with_holes_2& pol_wh)`. +`Polygon_2 operator()(const Polygon_with_holes_2& pol_wh)`. */ typedef unspecified_type Construct_outer_boundary; /*! A functor for constructing the container of holes of a polygon with holes. It returns the begin/end iterators for the holes It uses the operator -`std::pair operator()(const General_polygon_with_holes_2& pol_wh)`. +`std::pair operator()(const Polygon_with_holes_2& pol_wh)`. */ typedef unspecified_type Construct_holes; /*! A functor for checking if polygon with holes has no outer boundary. It uses the operator -`bool operator()(const General_polygon_with_holes_2& pol_wh)`. +`bool operator()(const Polygon_with_holes_2& pol_wh)`. */ typedef unspecified_type Is_unbounded; @@ -126,7 +126,7 @@ Construct_curves_2 construct_curves_2_object(); /*! returns a functor that constructs a polygon with holes. */ -Construct_general_polygon_with_holes_2 construct_polygon_with_holes_2_object() const; +Construct_polygon_with_holes_2 construct_polygon_with_holes_2_object() const; /*! returns a functor that obtains the outer boundary of a polygon with holes. From f17e5386bffc85c7322622af664f8ef0a60a9920 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 16:16:43 +0200 Subject: [PATCH 04/11] Fixed type requirement by GeneralPolygonWithHoles_2 concept --- .../include/CGAL/Gps_segment_traits_2.h | 88 +++++++------------ .../include/CGAL/Gps_traits_2.h | 79 +++++++---------- 2 files changed, 64 insertions(+), 103 deletions(-) diff --git a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h index 3704f08aa67..2beaff922a6 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h @@ -26,20 +26,18 @@ namespace CGAL { -template < class Kernel_, - class Container_ = std::vector, - class Arr_seg_traits_ = Arr_segment_traits_2 > -class Gps_segment_traits_2 : public Arr_seg_traits_ -{ - typedef Arr_seg_traits_ Base; - typedef Gps_segment_traits_2 Self; +template , + typename ArrSegmentTraits = Arr_segment_traits_2 > +class Gps_segment_traits_2 : public ArrSegmentTraits { + typedef ArrSegmentTraits Base; + typedef Gps_segment_traits_2 Self; public: - // Polygon_2 type is required by GeneralPolygonSetTraits Concept typedef CGAL::Polygon_2 Polygon_2; // Polygon_2 is a model of the GeneralPolygon2 concept. - typedef Polygon_2 General_polygon_2; + typedef Polygon_2 General_polygon_2; // Polygon_with_holes_2 can be a simple polygon , with holes that are // entirely inside him , or some vertices of the polygon and its holes @@ -49,7 +47,7 @@ public: typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; // Polygon_with_Holes_2 is a model of the GeneralPolygonWithHoles2 concept. - typedef Polygon_with_holes_2 General_polygon_with_holes_2; + typedef Polygon_with_holes_2 General_polygon_with_holes_2; typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; typedef Polygon_2_curve_iterator @@ -64,7 +62,7 @@ public: * A functor for constructing a polygon from a range of segments. */ class Construct_polygon_2 { - typedef Gps_segment_traits_2 Self; + typedef Gps_segment_traits_2 Self; typedef Gps_traits_adaptor Traits_adaptor; /*! The traits (in case it has state) */ @@ -101,11 +99,9 @@ public: class Construct_curves_2 { public: std::pair - operator()(const General_polygon_2& pgn) const - { + operator()(const Polygon_2& pgn) const { Curve_const_iterator c_begin(&pgn, pgn.vertex_pairs_begin()); Curve_const_iterator c_end(&pgn, pgn.vertex_pairs_end()); - return (std::make_pair(c_begin, c_end)); } }; @@ -121,39 +117,30 @@ public: */ class Construct_outer_boundary { public: - General_polygon_2 operator()(const General_polygon_with_holes_2& pol_wh) - const - { - return pol_wh.outer_boundary(); - } + Polygon_2 operator()(const Polygon_with_holes_2& pol_wh) const + { return pol_wh.outer_boundary(); } }; Construct_outer_boundary construct_outer_boundary_object() const - { - return Construct_outer_boundary(); - } + { return Construct_outer_boundary(); } - /* typedef from General_polygon_with_holes_2. + /* typedef from Polygon_with_holes_2. * Hole_const_iterator nested type is required by * GeneralPolygonWithHoles2 concept */ - /*A functor for constructing the container of holes of a polygon with holes. - * It returns ths begin/end iterators for the holes + /* A functor for constructing the container of holes of a polygon with holes. + * It returns the begin/end iterators for the holes */ class Construct_holes { public: std::pair - operator()(const General_polygon_with_holes_2& pol_wh) const - { - return std::make_pair(pol_wh.holes_begin(), pol_wh.holes_end()); - } + operator()(const Polygon_with_holes_2& pol_wh) const + { return std::make_pair(pol_wh.holes_begin(), pol_wh.holes_end()); } }; Construct_holes construct_holes_object() const - { - return Construct_holes(); - } + { return Construct_holes(); } /* A functor for constructing a General_polygon_with_holes from a * General_Polygon (and possibly a range of holes). @@ -165,25 +152,19 @@ public: * polygons representing the holes must be strictly simple and pairwise * disjoint, except perhaps at the vertices. */ - class Construct_general_polygon_with_holes_2 { + class Construct_polygon_with_holes_2 { public: - General_polygon_with_holes_2 operator()(const General_polygon_2& - pgn_boundary) const - { - return General_polygon_with_holes_2(pgn_boundary); - } - template - General_polygon_with_holes_2 operator()(const General_polygon_2& - pgn_boundary, - HolesInputIterator h_begin, - HolesInputIterator h_end) const - { - return General_polygon_with_holes_2(pgn_boundary, h_begin,h_end); - } + Polygon_with_holes_2 operator()(const Polygon_2& pgn_boundary) const + { return Polygon_with_holes_2(pgn_boundary); } + + template + Polygon_with_holes_2 operator()(const Polygon_2& pgn_boundary, + HolesInputIterator h_begin, + HolesInputIterator h_end) const + { return Polygon_with_holes_2(pgn_boundary, h_begin,h_end); } }; - Construct_general_polygon_with_holes_2 construct_polygon_with_holes_2_object() - const + Construct_polygon_with_holes_2 construct_polygon_with_holes_2_object() const { return Construct_general_polygon_with_holes_2(); } @@ -191,16 +172,11 @@ public: //functor returns true if the outer boundary is unbounded, and false otherwise. class Is_unbounded { public: - bool operator()(const General_polygon_with_holes_2& pol_wh) const - { - return pol_wh.is_unbounded(); - } + bool operator()(const Polygon_with_holes_2& pol_wh) const + { return pol_wh.is_unbounded(); } }; - Is_unbounded construct_is_unbounded_object() const - { - return Is_unbounded(); - } + Is_unbounded is_unbounded_object() const { return Is_unbounded(); } }; } //namespace CGAL diff --git a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h index a402e5c7f52..7ccc797329d 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h @@ -25,34 +25,30 @@ namespace CGAL { template > -class Gps_traits_2 : public Arr_traits -{ - typedef Arr_traits Base; - typedef Gps_traits_2 Self; + typename GeneralPolygon_2 = General_polygon_2 > +class Gps_traits_2 : public ArrTraits_2 { + typedef ArrTraits_2 Base; + typedef Gps_traits_2 Self; public: - typedef typename Base::Point_2 Point_2; typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; typedef typename Base::Multiplicity Multiplicity; //Polygon_2 type is required by GeneralPolygonSetTraits Concept - typedef General_polygon_t Polygon_2; + typedef GeneralPolygon_2 Polygon_2; //Polygon_2 is a model of the GeneralPolygon2 concept typedef Polygon_2 General_polygon_2; //Polygon_with_holes_2 type required by GeneralPolygonSetTraits Concept. - typedef CGAL::General_polygon_with_holes_2 - Polygon_with_holes_2; + typedef CGAL::General_polygon_with_holes_2 Polygon_with_holes_2; //Polygon_with_Holes_2 is a model of the GeneralPolygonWithHoles2 concept. typedef Polygon_with_holes_2 General_polygon_with_holes_2; - typedef typename General_polygon_2::Curve_const_iterator - Curve_const_iterator; + typedef typename Polygon_2::Curve_const_iterator Curve_const_iterator; - typedef typename General_polygon_with_holes_2::Hole_const_iterator + typedef typename Polygon_with_holes_2::Hole_const_iterator Hole_const_iterator; typedef typename Base::Compare_endpoints_xy_2 Compare_endpoints_xy_2; @@ -64,9 +60,9 @@ public: */ class Construct_polygon_2 { public: - template - void operator()(XCurveIterator begin, XCurveIterator end, - General_polygon_2& pgn) const + template + void + operator()(XCurveIterator begin, XCurveIterator end, Polygon_2& pgn) const { pgn.init(begin, end); } }; @@ -76,12 +72,10 @@ public: /*! * A functor for scanning all x-monotone curves that form a polygon boundary. */ - class Construct_curves_2 - { + class Construct_curves_2 { public: - std::pair - operator()(const General_polygon_2& pgn) const + operator()(const Polygon_2& pgn) const { return std::make_pair(pgn.curves_begin(), pgn.curves_end()); } }; @@ -106,30 +100,26 @@ public: /*A functor for constructing the outer boundary of a polygon with holes*/ class Construct_outer_boundary { public: - General_polygon_2 operator()(const General_polygon_with_holes_2& pol_wh) - const + Polygon_2 operator()(const Polygon_with_holes_2& pol_wh) const { return pol_wh.outer_boundary(); } }; Construct_outer_boundary construct_outer_boundary_object() const { return Construct_outer_boundary(); } - /* typedef from General_polygon_with_holes_2. Hole_const_iterator nested type - * is required by GeneralPolygonWithHoles2 concept + /* A functor for constructing the container of holes of a polygon with holes */ - /*A functor for constructing the container of holes of a polygon with holes*/ class Construct_holes { public: std::pair - operator()(const General_polygon_with_holes_2& pol_wh) const + operator()(const Polygon_with_holes_2& pol_wh) const { return std::make_pair(pol_wh.holes_begin(), pol_wh.holes_end()); } }; - Construct_holes construct_holes_object() const - { return Construct_holes(); } + Construct_holes construct_holes_object() const { return Construct_holes(); } - /* A functor for constructing a General_polygon_with_holes from a - * General_Polygon (and possibly a range of holes). + /* A functor for constructing a Polygon_with_holes_2 from a + * Polygon_2 (and possibly a range of holes). * * constructs a general polygon with holes using a given general polygon * outer as the outer boundary and a given range of holes. If outer is an @@ -138,28 +128,26 @@ public: * polygons representing the holes must be strictly simple and pairwise * disjoint, except perhaps at the vertices. */ - class Construct_general_polygon_with_holes_2 { + class Construct_polygon_with_holes_2 { public: General_polygon_with_holes_2 - operator()(const General_polygon_2& pgn_boundary) const - { return General_polygon_with_holes_2(pgn_boundary); } + operator()(const Polygon_2& pgn_boundary) const + { return Polygon_with_holes_2(pgn_boundary); } template - General_polygon_with_holes_2 - operator()(const General_polygon_2& pgn_boundary, - HolesInputIterator h_begin, - HolesInputIterator h_end) const - { return General_polygon_with_holes_2(pgn_boundary, h_begin,h_end); } + Polygon_with_holes_2 operator()(const Polygon_2& pgn_boundary, + HolesInputIterator h_begin, + HolesInputIterator h_end) const + { return Polygon_with_holes_2(pgn_boundary, h_begin,h_end); } }; - Construct_general_polygon_with_holes_2 construct_polygon_with_holes_2_object() - const - { return Construct_general_polygon_with_holes_2(); } + Construct_polygon_with_holes_2 construct_polygon_with_holes_2_object() const + { return Construct_polygon_with_holes_2(); } // Return true if the outer boundary is empty, and false otherwise. class Is_unbounded { public: - bool operator()(const General_polygon_with_holes_2& pol_wh) const + bool operator()(const Polygon_with_holes_2& pol_wh) const { return pol_wh.is_unbounded(); } }; @@ -202,9 +190,7 @@ public: { return m_traits.equal_2_object()(cv1, cv2); } //! Compare two general polygons - bool operator()(const General_polygon_2& pgn1, const General_polygon_2& pgn2) - const - { + bool operator()(const Polygon_2& pgn1, const Polygon_2& pgn2) const { if (pgn1.size() != pgn2.size()) return false; if (pgn1.is_empty() && ! pgn2.is_empty()) return false; if (pgn2.is_empty()) return false; @@ -224,9 +210,8 @@ public: } //! Compare two general polygons - bool operator()(const General_polygon_with_holes_2& pgn1, - const General_polygon_with_holes_2& pgn2) const { - + bool operator()(const Polygon_with_holes_2& pgn1, + const Polygon_with_holes_2& pgn2) const { if (! operator()(pgn1.outer_boundary(), pgn2.outer_boundary())) return false; if (pgn1.number_of_holes(), pgn2.number_of_holes()) return false; From 8eeffb0335cc7b467fd94502a92d51e1373dc53c Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 16:26:15 +0200 Subject: [PATCH 05/11] Added a specific comment about backward compatibility --- .../include/CGAL/Gps_segment_traits_2.h | 10 ++++++---- Boolean_set_operations_2/include/CGAL/Gps_traits_2.h | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h index 2beaff922a6..3cbb7b7f5c6 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h @@ -35,9 +35,10 @@ class Gps_segment_traits_2 : public ArrSegmentTraits { public: // Polygon_2 type is required by GeneralPolygonSetTraits Concept - typedef CGAL::Polygon_2 Polygon_2; - // Polygon_2 is a model of the GeneralPolygon2 concept. - typedef Polygon_2 General_polygon_2; + typedef CGAL::Polygon_2 Polygon_2; + + // Backward compatibility + typedef Polygon_2 General_polygon_2; // Polygon_with_holes_2 can be a simple polygon , with holes that are // entirely inside him , or some vertices of the polygon and its holes @@ -46,8 +47,9 @@ public: // Polygon_with_holes_2 type required by GeneralPolygonSetTraits Concept. typedef CGAL::Polygon_with_holes_2 Polygon_with_holes_2; - // Polygon_with_Holes_2 is a model of the GeneralPolygonWithHoles2 concept. + // Backward compatibility typedef Polygon_with_holes_2 General_polygon_with_holes_2; + typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; typedef Polygon_2_curve_iterator diff --git a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h index 7ccc797329d..5ba32601267 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h @@ -35,14 +35,14 @@ public: typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; typedef typename Base::Multiplicity Multiplicity; - //Polygon_2 type is required by GeneralPolygonSetTraits Concept + // Polygon_2 type is required by GeneralPolygonSetTraits Concept typedef GeneralPolygon_2 Polygon_2; - //Polygon_2 is a model of the GeneralPolygon2 concept + // Backward compatibility typedef Polygon_2 General_polygon_2; - //Polygon_with_holes_2 type required by GeneralPolygonSetTraits Concept. + // Polygon_with_holes_2 type required by GeneralPolygonSetTraits Concept. typedef CGAL::General_polygon_with_holes_2 Polygon_with_holes_2; - //Polygon_with_Holes_2 is a model of the GeneralPolygonWithHoles2 concept. + // Backward compatibility typedef Polygon_with_holes_2 General_polygon_with_holes_2; From 76a97df1a1b0848dd8ec8dd7d8ca15ac62885aac Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 16:47:12 +0200 Subject: [PATCH 06/11] Fixed GeneralPolygonWithHoles_2 concept: requires now nested Polygon_2 type instead of General_polygon_2 --- .../include/CGAL/Gps_segment_traits_2.h | 4 +- .../include/CGAL/Gps_traits_2.h | 5 +- .../Concepts/GeneralPolygonWithHoles_2.h | 96 +++++----- Polygon/doc/Polygon/PackageDescription.txt | 3 +- .../CGAL/General_polygon_with_holes_2.h | 165 ++++++------------ .../include/CGAL/create_offset_polygons_2.h | 8 +- 6 files changed, 107 insertions(+), 174 deletions(-) diff --git a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h index 3cbb7b7f5c6..71947eba0f9 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h @@ -144,8 +144,8 @@ public: Construct_holes construct_holes_object() const { return Construct_holes(); } - /* A functor for constructing a General_polygon_with_holes from a - * General_Polygon (and possibly a range of holes). + /* A functor for constructing a Polygon_with_holes from a polygon (and + * possibly a range of holes). * * constructs a general polygon with holes using a given general polygon * outer as the outer boundary and a given range of holes. If outer is an diff --git a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h index 5ba32601267..18de261175a 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h @@ -24,7 +24,7 @@ namespace CGAL { -template > class Gps_traits_2 : public ArrTraits_2 { typedef ArrTraits_2 Base; @@ -130,8 +130,7 @@ public: */ class Construct_polygon_with_holes_2 { public: - General_polygon_with_holes_2 - operator()(const Polygon_2& pgn_boundary) const + Polygon_with_holes_2 operator()(const Polygon_2& pgn_boundary) const { return Polygon_with_holes_2(pgn_boundary); } template diff --git a/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h b/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h index 6291a2bb62b..7488f20a2d7 100644 --- a/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h +++ b/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h @@ -1,22 +1,18 @@ - -/*! -\ingroup PkgPolygon2Concepts -\cgalConcept - -\cgalRefines `DefaultConstructible` -\cgalRefines `CopyConstructible` -\cgalRefines `Assignable` - - -A model of this concept represents a general polygon with holes. The -concept requires the ability to access the general polygon that -represents the outer boundary and the general polygons that represent -the holes. - -\cgalHasModel `CGAL::General_polygon_with_holes_2` -\cgalHasModel `CGAL::Polygon_with_holes_2` - -*/ +/*! \ingroup PkgPolygon2Concepts + * \cgalConcept + * + * \cgalRefines `DefaultConstructible` + * \cgalRefines `CopyConstructible` + * \cgalRefines `Assignable` + * + * A model of this concept represents a general polygon with holes. The + * concept requires the ability to access the general polygon that + * represents the outer boundary and the general polygons that represent + * the holes. + * + * \cgalHasModel `CGAL::General_polygon_with_holes_2` + * \cgalHasModel `CGAL::Polygon_with_holes_2` + */ class GeneralPolygonWithHoles_2 { public: @@ -24,16 +20,13 @@ public: /// \name Types /// @{ -/*! -the general-polygon type used to represent the outer boundary and each hole. -*/ -typedef unspecified_type General_polygon_2; +/*! the polygon type used to represent the outer boundary and each hole. + */ +typedef unspecified_type Polygon_2; -/*! -a bidirectional iterator -over the polygonal holes. Its value type is -`General_polygon_2`. -*/ +/*! a bidirectional iterator + * over the polygonal holes. Its value type is `Polygon_2`. + */ typedef unspecified_type Hole_const_iterator; /// @} @@ -41,27 +34,24 @@ typedef unspecified_type Hole_const_iterator; /// \name Creation /// @{ -/*! -constructs a general polygon with holes using a given general polygon -`outer` as the outer boundary and a given range of holes. If `outer` -is an empty general polygon, then an unbounded polygon with holes will be -created. The holes must be contained inside the outer boundary, and the -polygons representing the holes must be simple and pairwise disjoint, except -perhaps at the vertices. -*/ -template -GeneralPolygonWithHoles_2(General_polygon_2 & outer, -InputIterator begin, InputIterator end); +/*! constructs a general polygon with holes using a given general polygon + * `outer` as the outer boundary and a given range of holes. If `outer` is an + * empty general polygon, then an unbounded polygon with holes will be + * created. The holes must be contained inside the outer boundary, and the + * polygons representing the holes must be simple and pairwise disjoint, except + * perhaps at the vertices. + */ +template +GeneralPolygonWithHoles_2(Polygon_2 & outer, + InputIterator begin, InputIterator end); /// @} /// \name Predicates /// @{ -/*! -returns `true` if the outer boundary is empty, and `false` -otherwise. -*/ +/*! returns `true` if the outer boundary is empty, and `false` otherwise. + */ bool is_unbounded(); /// @} @@ -69,22 +59,20 @@ bool is_unbounded(); /// \name Access Functions /// @{ -/*! -returns the general polygon that represents the outer boundary. Note that this polygon is not necessarily a valid (simple) general polygon because it may be relatively simple. -*/ -const General_polygon_2 & outer_boundary() const; +/*! returns the general polygon that represents the outer boundary. Note that + * this polygon is not necessarily a valid (simple) general polygon because it + * may be relatively simple. + */ +const Polygon_2& outer_boundary() const; -/*! -returns the begin iterator of the holes. -*/ +/*! returns the begin iterator of the holes. + */ Hole_const_iterator holes_begin() const; -/*! -returns the past-the-end iterator of the holes. -*/ +/*! returns the past-the-end iterator of the holes. + */ Hole_const_iterator holes_end() const; /// @} }; /* end GeneralPolygonWithHoles_2 */ - diff --git a/Polygon/doc/Polygon/PackageDescription.txt b/Polygon/doc/Polygon/PackageDescription.txt index dc5e194db4e..e5c9d156714 100644 --- a/Polygon/doc/Polygon/PackageDescription.txt +++ b/Polygon/doc/Polygon/PackageDescription.txt @@ -54,7 +54,7 @@ The assertion flags for the polygons and polygon operations use \cgalCRPSection{Classes} - `CGAL::Polygon_2` - `CGAL::Polygon_with_holes_2` -- `CGAL::General_polygon_with_holes_2` +- `CGAL::General_polygon_with_holes_2` \cgalCRPSection{Global Functions} - `CGAL::area_2()` @@ -76,4 +76,3 @@ The assertion flags for the polygons and polygon operations use - \link PkgDrawPolygonWithHoles2 CGAL::draw() \endlink */ - diff --git a/Polygon/include/CGAL/General_polygon_with_holes_2.h b/Polygon/include/CGAL/General_polygon_with_holes_2.h index f52c2f284b6..1266ddb9844 100644 --- a/Polygon/include/CGAL/General_polygon_with_holes_2.h +++ b/Polygon/include/CGAL/General_polygon_with_holes_2.h @@ -23,141 +23,91 @@ namespace CGAL { -/*! -\ingroup PkgPolygon2Ref - -The class `General_polygon_with_holes_2` models the concept -`GeneralPolygonWithHoles_2`. It represents a general polygon with -holes. It is parameterized with a type `Polygon` used to define -the exposed type `General_polygon_2`. This type represents the -outer boundary of the general polygon and the outer boundaries of -each hole. - -\tparam Polygon_ must have input and output operators. - -\cgalModels `GeneralPolygonWithHoles_2` - -*/ -template -class General_polygon_with_holes_2 -{ +/*! \ingroup PkgPolygon2Ref + * + * The class `General_polygon_with_holes_2` models the concept + * `GeneralPolygonWithHoles_2`. It represents a general polygon with holes. + * It is parameterized with a type `Polygon` used to define the exposed + * type `Polygon_2`. This type represents the outer boundary of the general + * polygon and each hole. + * + * \tparam Polygon_ must have input and output operators. + * + * \cgalModels `GeneralPolygonWithHoles_2` + */ +template +class General_polygon_with_holes_2 { public: - /// \name Definition /// @{ /// polygon without hole type - typedef Polygon_ General_polygon_2; + typedef Polygon_ Polygon_2; + + // Backward compatibility + typedef Polygon_2 General_polygon_2; /// @} - typedef std::deque Holes_container; + typedef std::deque Holes_container; typedef typename Holes_container::iterator Hole_iterator; typedef typename Holes_container::const_iterator Hole_const_iterator; - typedef unsigned int Size; + typedef unsigned int Size; - General_polygon_with_holes_2() : m_pgn() + General_polygon_with_holes_2() : m_pgn() {} + + + explicit General_polygon_with_holes_2(const Polygon_2& pgn_boundary) : + m_pgn(pgn_boundary) {} - - explicit General_polygon_with_holes_2(const General_polygon_2& pgn_boundary) - : m_pgn(pgn_boundary) + template + General_polygon_with_holes_2(const Polygon_2& pgn_boundary, + HolesInputIterator h_begin, + HolesInputIterator h_end) : + m_pgn(pgn_boundary), + m_holes(h_begin, h_end) {} + Holes_container& holes() { return m_holes; } - template - General_polygon_with_holes_2(const General_polygon_2& pgn_boundary, - HolesInputIterator h_begin, - HolesInputIterator h_end) : m_pgn(pgn_boundary), - m_holes(h_begin, h_end) - {} + const Holes_container& holes() const { return m_holes; } - Holes_container& holes() - { - return m_holes; - } + Hole_iterator holes_begin() { return m_holes.begin(); } - const Holes_container& holes() const - { - return m_holes; - } + Hole_iterator holes_end() { return m_holes.end(); } - Hole_iterator holes_begin() - { - return m_holes.begin(); - } + Hole_const_iterator holes_begin() const { return m_holes.begin(); } - Hole_iterator holes_end() - { - return m_holes.end(); - } + Hole_const_iterator holes_end() const { return m_holes.end(); } - Hole_const_iterator holes_begin() const - { - return m_holes.begin(); - } + bool is_unbounded() const { return m_pgn.is_empty(); } - Hole_const_iterator holes_end() const - { - return m_holes.end(); - } + Polygon_2& outer_boundary() { return m_pgn; } - bool is_unbounded() const - { - return m_pgn.is_empty(); - } + const Polygon_2& outer_boundary() const { return m_pgn; } - General_polygon_2& outer_boundary() - { - return m_pgn; - } + void add_hole(const Polygon_2& pgn_hole) { m_holes.push_back(pgn_hole); } - const General_polygon_2& outer_boundary() const - { - return m_pgn; - } + void erase_hole(Hole_iterator hit) { m_holes.erase(hit); } - void add_hole(const General_polygon_2& pgn_hole) - { - m_holes.push_back(pgn_hole); - } + bool has_holes() const { return (!m_holes.empty()); } - void erase_hole(Hole_iterator hit) - { - m_holes.erase(hit); - } + Size number_of_holes() const { return static_cast(m_holes.size()); } - bool has_holes() const - { - return (!m_holes.empty()); - } - - Size number_of_holes() const - { - return static_cast(m_holes.size()); - } - - void clear() - { + void clear() { m_pgn.clear(); m_holes.clear(); } - bool is_plane() const - { - return (m_pgn.is_empty() && m_holes.empty()); - } - - + bool is_plane() const { return (m_pgn.is_empty() && m_holes.empty()); } protected: - - General_polygon_2 m_pgn; - Holes_container m_holes; + Polygon_2 m_pgn; + Holes_container m_holes; }; - //-----------------------------------------------------------------------// // operator<< //-----------------------------------------------------------------------// @@ -177,10 +127,9 @@ boundary is exported followed by the curves themselves. \relates General_polygon_with_holes_2 */ -template -std::ostream -&operator<<(std::ostream &os, const General_polygon_with_holes_2& p) -{ +template +std::ostream& +operator<<(std::ostream& os, const General_polygon_with_holes_2& p) { typename General_polygon_with_holes_2::Hole_const_iterator hit; switch(IO::get_mode(os)) { @@ -225,19 +174,17 @@ outer boundary is followed by the curves themselves. \relates General_polygon_with_holes_2 */ -template -std::istream &operator>>(std::istream &is, General_polygon_with_holes_2& p) -{ +template +std::istream& +operator>>(std::istream& is, General_polygon_with_holes_2& p) { p.clear(); is >> p.outer_boundary(); unsigned int n_holes; is >> n_holes; - if (is) - { + if (is) { Polygon_ pgn_hole; - for (unsigned int i=0; i> pgn_hole; p.add_hole(pgn_hole); } diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h index 8d0ca0f2bc1..42ea8cadcf1 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -50,7 +50,7 @@ struct Is_same_type { typedef Tag_true type ; } ; // The return type of create_interior/exterior_skeleton_and_offset_polygons_2: // - if polygon input is a model of 'GeneralPolygonWithHoles_2', the return type -// should be the internal (hole-less) polygon type GeneralPolygonWithHoles_2::General_polygon_2 +// should be the internal (hole-less) polygon type GeneralPolygonWithHoles_2::Polygon_2 // - if polygon input is just a sequence container of points (e.g. Polygon_2), then the same type // is expected in output template ::type>::Kernel, + typename Polygon::Polygon_2>::type>::Kernel, OfK>::value, - typename Polygon::General_polygon_2, // correct kernel + typename Polygon::Polygon_2, // correct kernel CGAL::Polygon_2 /*incorrect kernel*/ >::type type; }; @@ -85,7 +85,7 @@ struct Default_return_polygon_with_holes_type // Polygon type supports holes { typedef typename std::conditional::type>::Kernel, + typename Polygon::Polygon_2>::type>::Kernel, OfK>::value, Polygon, // correct kernel CGAL::Polygon_with_holes_2 /*incorrect kernel*/ >::type type; From 4dbf509f7ca8e5b1298607b42bcc1e7f713da547 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 16:47:12 +0200 Subject: [PATCH 07/11] Fixed GeneralPolygonWithHoles_2 concept: requires now nested Polygon_2 type instead of General_polygon_2 --- .../Gps_on_surface_base_2.h | 2 +- .../Gps_on_surface_base_2_impl.h | 8 +- .../include/CGAL/Gps_segment_traits_2.h | 4 +- .../include/CGAL/Gps_traits_2.h | 5 +- .../Concepts/GeneralPolygonWithHoles_2.h | 96 +++++----- Polygon/doc/Polygon/PackageDescription.txt | 3 +- .../CGAL/General_polygon_with_holes_2.h | 165 ++++++------------ .../include/CGAL/create_offset_polygons_2.h | 8 +- 8 files changed, 112 insertions(+), 179 deletions(-) diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h index b8c13c6a8f9..81c6f421171 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h @@ -1467,7 +1467,7 @@ protected: bool _is_plane(const Polygon_with_holes_2& pgn) const { //typedef typename Traits_2::Is_unbounded Is_unbounded; - bool unbounded = m_traits->construct_is_unbounded_object()(pgn); + bool unbounded = m_traits->is_unbounded_object()(pgn); std::pair pair = m_traits->construct_holes_object()(pgn); diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2_impl.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2_impl.h index 56564f2ff7b..f35d5486c6b 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2_impl.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2_impl.h @@ -469,7 +469,7 @@ template for( ; pwh_begin != pwh_end; ++pwh_begin) { ValidationPolicy::is_valid(*pwh_begin, *m_traits); - is_unbounded = (is_unbounded || m_traits->construct_is_unbounded_object()(*pwh_begin)); + is_unbounded = (is_unbounded || m_traits->is_unbounded_object()(*pwh_begin)); // is_unbounded = (is_unbounded || pwh_begin->is_unbounded()); _construct_curves(*pwh_begin, std::back_inserter(xcurve_list)); } @@ -517,7 +517,7 @@ template for( ; p_begin != p_end; ++p_begin) { // is_unbounded = (is_unbounded || p_begin->is_unbounded()); - is_unbounded = (is_unbounded || m_traits->construct_is_unbounded_object()(*p_begin)); + is_unbounded = (is_unbounded || m_traits->is_unbounded_object()(*p_begin)); _construct_curves(*p_begin, std::back_inserter(xcurve_list)); } @@ -557,7 +557,7 @@ template insert_non_intersecting_curves(arr, xcurve_list.begin(), xcurve_list.end()); //if (pgn.is_unbounded()) - if (m_traits->construct_is_unbounded_object()(pgn)) + if (m_traits->is_unbounded_object()(pgn)) { for (Face_iterator fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) @@ -590,7 +590,7 @@ template _construct_curves(const Polygon_with_holes_2 & pgn, OutputIterator oi) { //if (!pgn.is_unbounded()) - if (!m_traits->construct_is_unbounded_object()(pgn)) + if (!m_traits->is_unbounded_object()(pgn)) { const Polygon_2& pgn_boundary = m_traits->construct_outer_boundary_object()(pgn); diff --git a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h index 3cbb7b7f5c6..71947eba0f9 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h @@ -144,8 +144,8 @@ public: Construct_holes construct_holes_object() const { return Construct_holes(); } - /* A functor for constructing a General_polygon_with_holes from a - * General_Polygon (and possibly a range of holes). + /* A functor for constructing a Polygon_with_holes from a polygon (and + * possibly a range of holes). * * constructs a general polygon with holes using a given general polygon * outer as the outer boundary and a given range of holes. If outer is an diff --git a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h index 5ba32601267..18de261175a 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_traits_2.h @@ -24,7 +24,7 @@ namespace CGAL { -template > class Gps_traits_2 : public ArrTraits_2 { typedef ArrTraits_2 Base; @@ -130,8 +130,7 @@ public: */ class Construct_polygon_with_holes_2 { public: - General_polygon_with_holes_2 - operator()(const Polygon_2& pgn_boundary) const + Polygon_with_holes_2 operator()(const Polygon_2& pgn_boundary) const { return Polygon_with_holes_2(pgn_boundary); } template diff --git a/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h b/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h index 6291a2bb62b..7488f20a2d7 100644 --- a/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h +++ b/Polygon/doc/Polygon/Concepts/GeneralPolygonWithHoles_2.h @@ -1,22 +1,18 @@ - -/*! -\ingroup PkgPolygon2Concepts -\cgalConcept - -\cgalRefines `DefaultConstructible` -\cgalRefines `CopyConstructible` -\cgalRefines `Assignable` - - -A model of this concept represents a general polygon with holes. The -concept requires the ability to access the general polygon that -represents the outer boundary and the general polygons that represent -the holes. - -\cgalHasModel `CGAL::General_polygon_with_holes_2` -\cgalHasModel `CGAL::Polygon_with_holes_2` - -*/ +/*! \ingroup PkgPolygon2Concepts + * \cgalConcept + * + * \cgalRefines `DefaultConstructible` + * \cgalRefines `CopyConstructible` + * \cgalRefines `Assignable` + * + * A model of this concept represents a general polygon with holes. The + * concept requires the ability to access the general polygon that + * represents the outer boundary and the general polygons that represent + * the holes. + * + * \cgalHasModel `CGAL::General_polygon_with_holes_2` + * \cgalHasModel `CGAL::Polygon_with_holes_2` + */ class GeneralPolygonWithHoles_2 { public: @@ -24,16 +20,13 @@ public: /// \name Types /// @{ -/*! -the general-polygon type used to represent the outer boundary and each hole. -*/ -typedef unspecified_type General_polygon_2; +/*! the polygon type used to represent the outer boundary and each hole. + */ +typedef unspecified_type Polygon_2; -/*! -a bidirectional iterator -over the polygonal holes. Its value type is -`General_polygon_2`. -*/ +/*! a bidirectional iterator + * over the polygonal holes. Its value type is `Polygon_2`. + */ typedef unspecified_type Hole_const_iterator; /// @} @@ -41,27 +34,24 @@ typedef unspecified_type Hole_const_iterator; /// \name Creation /// @{ -/*! -constructs a general polygon with holes using a given general polygon -`outer` as the outer boundary and a given range of holes. If `outer` -is an empty general polygon, then an unbounded polygon with holes will be -created. The holes must be contained inside the outer boundary, and the -polygons representing the holes must be simple and pairwise disjoint, except -perhaps at the vertices. -*/ -template -GeneralPolygonWithHoles_2(General_polygon_2 & outer, -InputIterator begin, InputIterator end); +/*! constructs a general polygon with holes using a given general polygon + * `outer` as the outer boundary and a given range of holes. If `outer` is an + * empty general polygon, then an unbounded polygon with holes will be + * created. The holes must be contained inside the outer boundary, and the + * polygons representing the holes must be simple and pairwise disjoint, except + * perhaps at the vertices. + */ +template +GeneralPolygonWithHoles_2(Polygon_2 & outer, + InputIterator begin, InputIterator end); /// @} /// \name Predicates /// @{ -/*! -returns `true` if the outer boundary is empty, and `false` -otherwise. -*/ +/*! returns `true` if the outer boundary is empty, and `false` otherwise. + */ bool is_unbounded(); /// @} @@ -69,22 +59,20 @@ bool is_unbounded(); /// \name Access Functions /// @{ -/*! -returns the general polygon that represents the outer boundary. Note that this polygon is not necessarily a valid (simple) general polygon because it may be relatively simple. -*/ -const General_polygon_2 & outer_boundary() const; +/*! returns the general polygon that represents the outer boundary. Note that + * this polygon is not necessarily a valid (simple) general polygon because it + * may be relatively simple. + */ +const Polygon_2& outer_boundary() const; -/*! -returns the begin iterator of the holes. -*/ +/*! returns the begin iterator of the holes. + */ Hole_const_iterator holes_begin() const; -/*! -returns the past-the-end iterator of the holes. -*/ +/*! returns the past-the-end iterator of the holes. + */ Hole_const_iterator holes_end() const; /// @} }; /* end GeneralPolygonWithHoles_2 */ - diff --git a/Polygon/doc/Polygon/PackageDescription.txt b/Polygon/doc/Polygon/PackageDescription.txt index dc5e194db4e..e5c9d156714 100644 --- a/Polygon/doc/Polygon/PackageDescription.txt +++ b/Polygon/doc/Polygon/PackageDescription.txt @@ -54,7 +54,7 @@ The assertion flags for the polygons and polygon operations use \cgalCRPSection{Classes} - `CGAL::Polygon_2` - `CGAL::Polygon_with_holes_2` -- `CGAL::General_polygon_with_holes_2` +- `CGAL::General_polygon_with_holes_2` \cgalCRPSection{Global Functions} - `CGAL::area_2()` @@ -76,4 +76,3 @@ The assertion flags for the polygons and polygon operations use - \link PkgDrawPolygonWithHoles2 CGAL::draw() \endlink */ - diff --git a/Polygon/include/CGAL/General_polygon_with_holes_2.h b/Polygon/include/CGAL/General_polygon_with_holes_2.h index f52c2f284b6..1266ddb9844 100644 --- a/Polygon/include/CGAL/General_polygon_with_holes_2.h +++ b/Polygon/include/CGAL/General_polygon_with_holes_2.h @@ -23,141 +23,91 @@ namespace CGAL { -/*! -\ingroup PkgPolygon2Ref - -The class `General_polygon_with_holes_2` models the concept -`GeneralPolygonWithHoles_2`. It represents a general polygon with -holes. It is parameterized with a type `Polygon` used to define -the exposed type `General_polygon_2`. This type represents the -outer boundary of the general polygon and the outer boundaries of -each hole. - -\tparam Polygon_ must have input and output operators. - -\cgalModels `GeneralPolygonWithHoles_2` - -*/ -template -class General_polygon_with_holes_2 -{ +/*! \ingroup PkgPolygon2Ref + * + * The class `General_polygon_with_holes_2` models the concept + * `GeneralPolygonWithHoles_2`. It represents a general polygon with holes. + * It is parameterized with a type `Polygon` used to define the exposed + * type `Polygon_2`. This type represents the outer boundary of the general + * polygon and each hole. + * + * \tparam Polygon_ must have input and output operators. + * + * \cgalModels `GeneralPolygonWithHoles_2` + */ +template +class General_polygon_with_holes_2 { public: - /// \name Definition /// @{ /// polygon without hole type - typedef Polygon_ General_polygon_2; + typedef Polygon_ Polygon_2; + + // Backward compatibility + typedef Polygon_2 General_polygon_2; /// @} - typedef std::deque Holes_container; + typedef std::deque Holes_container; typedef typename Holes_container::iterator Hole_iterator; typedef typename Holes_container::const_iterator Hole_const_iterator; - typedef unsigned int Size; + typedef unsigned int Size; - General_polygon_with_holes_2() : m_pgn() + General_polygon_with_holes_2() : m_pgn() {} + + + explicit General_polygon_with_holes_2(const Polygon_2& pgn_boundary) : + m_pgn(pgn_boundary) {} - - explicit General_polygon_with_holes_2(const General_polygon_2& pgn_boundary) - : m_pgn(pgn_boundary) + template + General_polygon_with_holes_2(const Polygon_2& pgn_boundary, + HolesInputIterator h_begin, + HolesInputIterator h_end) : + m_pgn(pgn_boundary), + m_holes(h_begin, h_end) {} + Holes_container& holes() { return m_holes; } - template - General_polygon_with_holes_2(const General_polygon_2& pgn_boundary, - HolesInputIterator h_begin, - HolesInputIterator h_end) : m_pgn(pgn_boundary), - m_holes(h_begin, h_end) - {} + const Holes_container& holes() const { return m_holes; } - Holes_container& holes() - { - return m_holes; - } + Hole_iterator holes_begin() { return m_holes.begin(); } - const Holes_container& holes() const - { - return m_holes; - } + Hole_iterator holes_end() { return m_holes.end(); } - Hole_iterator holes_begin() - { - return m_holes.begin(); - } + Hole_const_iterator holes_begin() const { return m_holes.begin(); } - Hole_iterator holes_end() - { - return m_holes.end(); - } + Hole_const_iterator holes_end() const { return m_holes.end(); } - Hole_const_iterator holes_begin() const - { - return m_holes.begin(); - } + bool is_unbounded() const { return m_pgn.is_empty(); } - Hole_const_iterator holes_end() const - { - return m_holes.end(); - } + Polygon_2& outer_boundary() { return m_pgn; } - bool is_unbounded() const - { - return m_pgn.is_empty(); - } + const Polygon_2& outer_boundary() const { return m_pgn; } - General_polygon_2& outer_boundary() - { - return m_pgn; - } + void add_hole(const Polygon_2& pgn_hole) { m_holes.push_back(pgn_hole); } - const General_polygon_2& outer_boundary() const - { - return m_pgn; - } + void erase_hole(Hole_iterator hit) { m_holes.erase(hit); } - void add_hole(const General_polygon_2& pgn_hole) - { - m_holes.push_back(pgn_hole); - } + bool has_holes() const { return (!m_holes.empty()); } - void erase_hole(Hole_iterator hit) - { - m_holes.erase(hit); - } + Size number_of_holes() const { return static_cast(m_holes.size()); } - bool has_holes() const - { - return (!m_holes.empty()); - } - - Size number_of_holes() const - { - return static_cast(m_holes.size()); - } - - void clear() - { + void clear() { m_pgn.clear(); m_holes.clear(); } - bool is_plane() const - { - return (m_pgn.is_empty() && m_holes.empty()); - } - - + bool is_plane() const { return (m_pgn.is_empty() && m_holes.empty()); } protected: - - General_polygon_2 m_pgn; - Holes_container m_holes; + Polygon_2 m_pgn; + Holes_container m_holes; }; - //-----------------------------------------------------------------------// // operator<< //-----------------------------------------------------------------------// @@ -177,10 +127,9 @@ boundary is exported followed by the curves themselves. \relates General_polygon_with_holes_2 */ -template -std::ostream -&operator<<(std::ostream &os, const General_polygon_with_holes_2& p) -{ +template +std::ostream& +operator<<(std::ostream& os, const General_polygon_with_holes_2& p) { typename General_polygon_with_holes_2::Hole_const_iterator hit; switch(IO::get_mode(os)) { @@ -225,19 +174,17 @@ outer boundary is followed by the curves themselves. \relates General_polygon_with_holes_2 */ -template -std::istream &operator>>(std::istream &is, General_polygon_with_holes_2& p) -{ +template +std::istream& +operator>>(std::istream& is, General_polygon_with_holes_2& p) { p.clear(); is >> p.outer_boundary(); unsigned int n_holes; is >> n_holes; - if (is) - { + if (is) { Polygon_ pgn_hole; - for (unsigned int i=0; i> pgn_hole; p.add_hole(pgn_hole); } diff --git a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h index 8d0ca0f2bc1..42ea8cadcf1 100644 --- a/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h +++ b/Straight_skeleton_2/include/CGAL/create_offset_polygons_2.h @@ -50,7 +50,7 @@ struct Is_same_type { typedef Tag_true type ; } ; // The return type of create_interior/exterior_skeleton_and_offset_polygons_2: // - if polygon input is a model of 'GeneralPolygonWithHoles_2', the return type -// should be the internal (hole-less) polygon type GeneralPolygonWithHoles_2::General_polygon_2 +// should be the internal (hole-less) polygon type GeneralPolygonWithHoles_2::Polygon_2 // - if polygon input is just a sequence container of points (e.g. Polygon_2), then the same type // is expected in output template ::type>::Kernel, + typename Polygon::Polygon_2>::type>::Kernel, OfK>::value, - typename Polygon::General_polygon_2, // correct kernel + typename Polygon::Polygon_2, // correct kernel CGAL::Polygon_2 /*incorrect kernel*/ >::type type; }; @@ -85,7 +85,7 @@ struct Default_return_polygon_with_holes_type // Polygon type supports holes { typedef typename std::conditional::type>::Kernel, + typename Polygon::Polygon_2>::type>::Kernel, OfK>::value, Polygon, // correct kernel CGAL::Polygon_with_holes_2 /*incorrect kernel*/ >::type type; From 08c3f7405cec2af304f9ecd18f07f2b1dcad9b4b Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 18:24:40 +0200 Subject: [PATCH 08/11] Updated 2D Polygon and 2D Reg. Bool. Set Ops changed --- Installation/CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index ae8b484a467..60d23ec62f8 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -112,11 +112,15 @@ Release date: December 2021 and [`oriented_side`](https://doc.cgal.org/5.4/Boolean_set_operations_2/group__boolean__oriented__side.html)) to control whether to use `Arr_polyline_traits_2` as default traits. It is the new default as it provides better performances in general. +- The concept `GeneralPolygonSetTraits_2` now requires the nested type `Construct_polygon_with_holes_2` instead of `Construct_general_polygon_with_holes_2`. + ### [3D Mesh Generation](https://doc.cgal.org/latest/Manual/packages.html#PkgMesh3) - Added support of weighted images for an improved quality of meshes generated from labeled images, along with a function `CGAL::Mesh_3::generate_label_weights()` to generate the weights. +### [2D Polygon](https://doc.cgal.org/5.4/Manual/packages.html#PkgPolygon2) +- The concept `GeneralPolygonWithHoles_2` now requires the nested type `Polygon_2` instead of `General_polygon_2`. [Release 5.3](https://github.com/CGAL/cgal/releases/tag/v5.3) ----------- From 04729e8e34b7623a8a4590ae2cdddf00d38b68b9 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 18:29:58 +0200 Subject: [PATCH 09/11] Renamed Construct_general_polygon_with_holes_2 => Construct_polygon_with_holes_2 --- Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h index 71947eba0f9..190b7337ec5 100644 --- a/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h +++ b/Boolean_set_operations_2/include/CGAL/Gps_segment_traits_2.h @@ -168,7 +168,7 @@ public: Construct_polygon_with_holes_2 construct_polygon_with_holes_2_object() const { - return Construct_general_polygon_with_holes_2(); + return Construct_polygon_with_holes_2(); } //functor returns true if the outer boundary is unbounded, and false otherwise. From 6fd9388c8cc411c55c29e431b8d1e101263cee2f Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Wed, 3 Nov 2021 18:32:40 +0200 Subject: [PATCH 10/11] Renamed Construct_general_polygon_with_holes_2 => Construct_polygon_with_holes_2 --- .../CGAL/Boolean_set_operations_2/Gps_polygon_validation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h index a248919084c..40e47f1f7f4 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_polygon_validation.h @@ -631,7 +631,7 @@ bool are_holes_and_boundary_pairwise_disjoint typedef std::pair Cci_pair; typedef typename Traits_2::Construct_curves_2 Construct_curves_2; - typedef typename Traits_2::Construct_general_polygon_with_holes_2 + typedef typename Traits_2::Construct_polygon_with_holes_2 Construct_polygon_with_holes_2; typedef Gps_polygon_validation_visitor Visitor; @@ -698,7 +698,7 @@ bool are_holes_and_boundary_pairwise_disjoint * whose performance is better than the join(pgn) */ Polygon_with_holes_2 empty_pwh = construct_pwh_functor(hole); - // traits.Construct_general_polygon_with_holes_2 (hole); + // traits.Construct_polygon_with_holes_2 (hole); // Polygon_with_holes_2 empty_pwh(hole); gps.insert(empty_pwh); num_of_holes++; From 2a30075975ac68e6eee37252ee6abf980c60cdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 10 Jan 2022 11:01:31 +0100 Subject: [PATCH 11/11] workaround doxygen warning --- Polygon/include/CGAL/General_polygon_with_holes_2.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polygon/include/CGAL/General_polygon_with_holes_2.h b/Polygon/include/CGAL/General_polygon_with_holes_2.h index 1266ddb9844..d7d0be256bb 100644 --- a/Polygon/include/CGAL/General_polygon_with_holes_2.h +++ b/Polygon/include/CGAL/General_polygon_with_holes_2.h @@ -43,9 +43,10 @@ public: /// @{ /// polygon without hole type typedef Polygon_ Polygon_2; - +#ifndef DOXYGEN_RUNNING // Backward compatibility typedef Polygon_2 General_polygon_2; +#endif /// @} typedef std::deque Holes_container;