Cleaned up; replaced `typedef` with `using`, etc.

This commit is contained in:
Efi Fogel 2025-08-26 21:58:34 +03:00
parent e5049d4b03
commit a74945062c
23 changed files with 647 additions and 809 deletions

View File

@ -8,8 +8,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com> // Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_ARR_OVERLAY_2_H #ifndef CGAL_ARR_OVERLAY_2_H
#define CGAL_ARR_OVERLAY_2_H #define CGAL_ARR_OVERLAY_2_H

View File

@ -8,7 +8,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Efi Fogel <efif@post.tau.ac.il> // Author(s) : Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_DO_INTERSECT_ARR_OVERLAY_SS_VISITOR_H #ifndef CGAL_DO_INTERSECT_ARR_OVERLAY_SS_VISITOR_H
#define CGAL_DO_INTERSECT_ARR_OVERLAY_SS_VISITOR_H #define CGAL_DO_INTERSECT_ARR_OVERLAY_SS_VISITOR_H

View File

@ -8,9 +8,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il> // Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il> // Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ARR_OVERLAY_SS_VISITOR_H #ifndef CGAL_ARR_OVERLAY_SS_VISITOR_H
#define CGAL_ARR_OVERLAY_SS_VISITOR_H #define CGAL_ARR_OVERLAY_SS_VISITOR_H

View File

@ -52,7 +52,7 @@ inline bool s_do_intersect(const Pgn1& pgn1, const Pgn2& pgn2) {
// With Traits // With Traits
template <typename InputIterator, typename Traits> template <typename InputIterator, typename Traits>
inline bool r_do_intersect(InputIterator begin, InputIterator end, inline bool r_do_intersect(InputIterator begin, InputIterator end,
Traits& traits, unsigned int k = 5) { Traits& traits, std::size_t k = 5) {
if (begin == end) return false; if (begin == end) return false;
General_polygon_set_2<Traits> gps(*begin, traits); General_polygon_set_2<Traits> gps(*begin, traits);
return gps.do_intersect(std::next(begin), end, k); return gps.do_intersect(std::next(begin), end, k);
@ -61,7 +61,7 @@ inline bool r_do_intersect(InputIterator begin, InputIterator end,
// Without Traits // Without Traits
template <typename InputIterator> template <typename InputIterator>
inline bool r_do_intersect(InputIterator begin, InputIterator end, inline bool r_do_intersect(InputIterator begin, InputIterator end,
unsigned int k = 5) { std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator>::value_type; using Pgn = typename std::iterator_traits<InputIterator>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);
@ -74,7 +74,7 @@ inline bool r_do_intersect(InputIterator begin, InputIterator end,
template <typename InputIterator1, typename InputIterator2, typename Traits> template <typename InputIterator1, typename InputIterator2, typename Traits>
inline bool r_do_intersect(InputIterator1 begin1, InputIterator1 end1, inline bool r_do_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
Traits& traits, unsigned int k = 5) { Traits& traits, std::size_t k = 5) {
if (begin1 == end1) return do_intersect(begin2, end2, traits, k); if (begin1 == end1) return do_intersect(begin2, end2, traits, k);
General_polygon_set_2<Traits> gps(*begin1, traits); General_polygon_set_2<Traits> gps(*begin1, traits);
return gps.do_intersect(std::next(begin1), end1, begin2, end2, k); return gps.do_intersect(std::next(begin1), end1, begin2, end2, k);
@ -84,7 +84,7 @@ inline bool r_do_intersect(InputIterator1 begin1, InputIterator1 end1,
template <typename InputIterator1, typename InputIterator2> template <typename InputIterator1, typename InputIterator2>
inline bool r_do_intersect (InputIterator1 begin1, InputIterator1 end1, inline bool r_do_intersect (InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
unsigned int k = 5) { std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator1>::value_type; using Pgn = typename std::iterator_traits<InputIterator1>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);
@ -162,7 +162,7 @@ inline OutputIterator s_intersection(const Pgn1& pgn1, const Pgn2& pgn2,
template <typename InputIterator, typename OutputIterator, typename Traits> template <typename InputIterator, typename OutputIterator, typename Traits>
inline OutputIterator r_intersection(InputIterator begin, InputIterator end, inline OutputIterator r_intersection(InputIterator begin, InputIterator end,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k = 5) { std::size_t k = 5) {
if (begin == end) return (oi); if (begin == end) return (oi);
General_polygon_set_2<Traits> gps(*begin, traits); General_polygon_set_2<Traits> gps(*begin, traits);
gps.intersection(std::next(begin), end, k); gps.intersection(std::next(begin), end, k);
@ -172,7 +172,7 @@ inline OutputIterator r_intersection(InputIterator begin, InputIterator end,
// Without Traits // Without Traits
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator r_intersection(InputIterator begin, InputIterator end, inline OutputIterator r_intersection(InputIterator begin, InputIterator end,
OutputIterator oi, unsigned int k = 5) { OutputIterator oi, std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator>::value_type; using Pgn = typename std::iterator_traits<InputIterator>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);
@ -189,7 +189,7 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator r_intersection(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator r_intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k = 5) { std::size_t k = 5) {
if (begin1 == end1) return r_intersection(begin2, end2, oi, traits, k); if (begin1 == end1) return r_intersection(begin2, end2, oi, traits, k);
General_polygon_set_2<Traits> gps(*begin1, traits); General_polygon_set_2<Traits> gps(*begin1, traits);
gps.intersection(std::next(begin1), end1, begin2, end2, k); gps.intersection(std::next(begin1), end1, begin2, end2, k);
@ -202,7 +202,7 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator inline OutputIterator
r_intersection(InputIterator1 begin1, InputIterator1 end1, r_intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, unsigned int k = 5) { OutputIterator oi, std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator1>::value_type; using Pgn = typename std::iterator_traits<InputIterator1>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);
@ -286,7 +286,7 @@ inline bool s_join(const Pgn1& pgn1, const Pgn2& pgn2, Pwh& pwh) {
template <typename InputIterator, typename OutputIterator, typename Traits> template <typename InputIterator, typename OutputIterator, typename Traits>
inline OutputIterator r_join(InputIterator begin, InputIterator end, inline OutputIterator r_join(InputIterator begin, InputIterator end,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k = 5) { std::size_t k = 5) {
if (begin == end) return oi; if (begin == end) return oi;
General_polygon_set_2<Traits> gps(*begin, traits); General_polygon_set_2<Traits> gps(*begin, traits);
gps.join(std::next(begin), end, k); gps.join(std::next(begin), end, k);
@ -296,7 +296,7 @@ inline OutputIterator r_join(InputIterator begin, InputIterator end,
// Without traits // Without traits
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator r_join(InputIterator begin, InputIterator end, inline OutputIterator r_join(InputIterator begin, InputIterator end,
OutputIterator oi, unsigned int k = 5) { OutputIterator oi, std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator>::value_type; using Pgn = typename std::iterator_traits<InputIterator>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);
@ -315,7 +315,7 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator r_join(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator r_join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k = 5) { std::size_t k = 5) {
if (begin1 == end1) return r_join(begin2, end2, oi, traits, k); if (begin1 == end1) return r_join(begin2, end2, oi, traits, k);
General_polygon_set_2<Traits> gps(*begin1, traits); General_polygon_set_2<Traits> gps(*begin1, traits);
gps.join(std::next(begin1), end1, begin2, end2, k); gps.join(std::next(begin1), end1, begin2, end2, k);
@ -327,7 +327,7 @@ template <typename InputIterator1, typename InputIterator2,
typename OutputIterator> typename OutputIterator>
inline OutputIterator r_join(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator r_join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, unsigned int k = 5) { OutputIterator oi, std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator1>::value_type; using Pgn = typename std::iterator_traits<InputIterator1>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);
@ -407,7 +407,7 @@ template <typename InputIterator, typename OutputIterator, typename Traits>
inline inline
OutputIterator r_symmetric_difference(InputIterator begin, InputIterator end, OutputIterator r_symmetric_difference(InputIterator begin, InputIterator end,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k = 5) { std::size_t k = 5) {
if (begin == end) return (oi); if (begin == end) return (oi);
General_polygon_set_2<Traits> gps(*begin, traits); General_polygon_set_2<Traits> gps(*begin, traits);
gps.symmetric_difference(std::next(begin), end, k); gps.symmetric_difference(std::next(begin), end, k);
@ -419,7 +419,7 @@ template <typename InputIterator, typename OutputIterator>
inline OutputIterator r_symmetric_difference(InputIterator begin, inline OutputIterator r_symmetric_difference(InputIterator begin,
InputIterator end, InputIterator end,
OutputIterator oi, OutputIterator oi,
unsigned int k = 5) { std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator>::value_type; using Pgn = typename std::iterator_traits<InputIterator>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);
@ -438,7 +438,7 @@ inline OutputIterator r_symmetric_difference(InputIterator1 begin1,
InputIterator2 begin2, InputIterator2 begin2,
InputIterator2 end2, InputIterator2 end2,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k = 5) { std::size_t k = 5) {
if (begin1 == end1) return r_symmetric_difference(begin2, end2, oi, traits, k); if (begin1 == end1) return r_symmetric_difference(begin2, end2, oi, traits, k);
General_polygon_set_2<Traits> gps(*begin1, traits); General_polygon_set_2<Traits> gps(*begin1, traits);
gps.symmetric_difference(std::next(begin1), end1, begin2, end2, k); gps.symmetric_difference(std::next(begin1), end1, begin2, end2, k);
@ -453,7 +453,7 @@ inline OutputIterator r_symmetric_difference(InputIterator1 begin1,
InputIterator2 begin2, InputIterator2 begin2,
InputIterator2 end2, InputIterator2 end2,
OutputIterator oi, OutputIterator oi,
unsigned int k = 5) { std::size_t k = 5) {
using Pgn = typename std::iterator_traits<InputIterator1>::value_type; using Pgn = typename std::iterator_traits<InputIterator1>::value_type;
typename Gps_polyline_traits<Pgn>::Traits traits; typename Gps_polyline_traits<Pgn>::Traits traits;
const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits); const typename Gps_polyline_traits<Pgn>::Polyline_traits& ptraits(traits);

View File

@ -8,8 +8,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com> // Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_BSO_2_GPS_AGG_META_TRAITS_H #ifndef CGAL_BSO_2_GPS_AGG_META_TRAITS_H
#define CGAL_BSO_2_GPS_AGG_META_TRAITS_H #define CGAL_BSO_2_GPS_AGG_META_TRAITS_H
@ -24,18 +24,17 @@
namespace CGAL { namespace CGAL {
template <typename Arrangement_> template <typename Arrangement_>
class Gps_agg_curve_data : public Curve_with_halfedge<Arrangement_> class Gps_agg_curve_data : public Curve_with_halfedge<Arrangement_> {
{
protected: protected:
typedef Arrangement_ Arrangement; using Arrangement = Arrangement_;
typedef typename Arrangement::Halfedge_handle Halfedge_handle; using Halfedge_handle = typename Arrangement::Halfedge_handle;
typedef Curve_with_halfedge<Arrangement_> Base; using Base = Curve_with_halfedge<Arrangement_>;
const Arrangement* m_arr; // pointer to the arrangement containing the edge. const Arrangement* m_arr; // pointer to the arrangement containing the edge.
unsigned int m_bc; // the boundary counter of the halfedge with the same std::size_t m_bc; // the boundary counter of the halfedge with the same
// direction as the curve // direction as the curve
unsigned int m_twin_bc; // the boundary counter of the halfedge with the same std::size_t m_twin_bc; // the boundary counter of the halfedge with the same
// direction as the curve // direction as the curve
public: public:
@ -47,24 +46,24 @@ public:
{} {}
Gps_agg_curve_data(const Arrangement* arr, Halfedge_handle he, Gps_agg_curve_data(const Arrangement* arr, Halfedge_handle he,
unsigned int bc, unsigned int twin_bc) : std::size_t bc, std::size_t twin_bc) :
Base(he), Base(he),
m_arr(arr), m_arr(arr),
m_bc(bc), m_bc(bc),
m_twin_bc(twin_bc) m_twin_bc(twin_bc)
{} {}
unsigned int bc() const { return m_bc; } std::size_t bc() const { return m_bc; }
unsigned int twin_bc() const { return m_twin_bc; } std::size_t twin_bc() const { return m_twin_bc; }
unsigned int& bc() { return m_bc; } std::size_t& bc() { return m_bc; }
unsigned int& twin_bc() { return m_twin_bc; } std::size_t& twin_bc() { return m_twin_bc; }
void set_bc(unsigned int bc) { m_bc = bc; } void set_bc(std::size_t bc) { m_bc = bc; }
void set_twin_bc(unsigned int twin_bc) { m_twin_bc = twin_bc; } void set_twin_bc(std::size_t twin_bc) { m_twin_bc = twin_bc; }
const Arrangement* arr() const { return m_arr; } const Arrangement* arr() const { return m_arr; }
}; };
@ -73,54 +72,50 @@ template <typename Arrangement_>
class Gps_agg_meta_traits : class Gps_agg_meta_traits :
public Gps_traits_decorator<typename Arrangement_::Traits_adaptor_2, public Gps_traits_decorator<typename Arrangement_::Traits_adaptor_2,
Gps_agg_curve_data<Arrangement_>, Gps_agg_curve_data<Arrangement_>,
Point_with_vertex<Arrangement_> > Point_with_vertex<Arrangement_>> {
{ using Arrangement = Arrangement_;
typedef Arrangement_ Arrangement; using Arr = Arrangement;
typedef Arrangement Arr;
typedef typename Arr::Traits_adaptor_2 Traits; using Traits = typename Arr::Traits_adaptor_2;
typedef Traits Gt2; using Gt2 = Traits;
typedef typename Gt2::X_monotone_curve_2 Base_x_monotone_curve_2; using Base_x_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
typedef typename Gt2::Point_2 Base_point_2; using Base_point_2 = typename Gt2::Point_2;
typedef typename Gt2::Construct_min_vertex_2 Base_Construct_min_vertex_2; using Base_Construct_min_vertex_2 = typename Gt2::Construct_min_vertex_2;
typedef typename Gt2::Construct_max_vertex_2 Base_Construct_max_vertex_2; using Base_Construct_max_vertex_2 = typename Gt2::Construct_max_vertex_2;
typedef typename Gt2::Compare_endpoints_xy_2 Base_Compare_endpoints_xy_2; using Base_Compare_endpoints_xy_2 = typename Gt2::Compare_endpoints_xy_2;
typedef typename Gt2::Compare_xy_2 Base_Compare_xy_2; using Base_Compare_xy_2 = typename Gt2::Compare_xy_2;
typedef typename Gt2::Compare_y_at_x_right_2 Base_Compare_y_at_x_right_2; using Base_Compare_y_at_x_right_2 = typename Gt2::Compare_y_at_x_right_2;
typedef typename Gt2::Compare_y_at_x_2 Base_Compare_y_at_x_2; using Base_Compare_y_at_x_2 = typename Gt2::Compare_y_at_x_2;
typedef typename Gt2::Intersect_2 Base_Intersect_2; using Base_Intersect_2 = typename Gt2::Intersect_2;
typedef typename Gt2::Split_2 Base_Split_2; using Base_Split_2 = typename Gt2::Split_2;
typedef typename Gt2::Parameter_space_in_x_2 Base_Parameter_space_in_x_2; using Base_Parameter_space_in_x_2 = typename Gt2::Parameter_space_in_x_2;
typedef typename Gt2::Compare_y_near_boundary_2 using Base_Compare_y_near_boundary_2 = typename Gt2::Compare_y_near_boundary_2;
Base_Compare_y_near_boundary_2;
typedef typename Gt2::Parameter_space_in_y_2 Base_Parameter_space_in_y_2; using Base_Parameter_space_in_y_2 = typename Gt2::Parameter_space_in_y_2;
typedef typename Gt2::Compare_x_near_boundary_2 using Base_Compare_x_near_boundary_2 = typename Gt2::Compare_x_near_boundary_2;
Base_Compare_x_near_boundary_2;
public: public:
typedef typename Gt2::Multiplicity Multiplicity; using Multiplicity = typename Gt2::Multiplicity;
typedef Gps_agg_curve_data<Arr> Curve_data; using Curve_data = Gps_agg_curve_data<Arr>;
typedef Point_with_vertex<Arr> Point_data; using Point_data = Point_with_vertex<Arr>;
private: private:
typedef Gps_agg_meta_traits<Arrangement> Self; using Self = Gps_agg_meta_traits<Arrangement>;
typedef Gps_traits_decorator<Gt2, Curve_data, Point_data> Base; using Base = Gps_traits_decorator<Gt2, Curve_data, Point_data>;
public: public:
typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; using X_monotone_curve_2 = typename Base::X_monotone_curve_2;
typedef typename Base::Point_2 Point_2; using Point_2 = typename Base::Point_2;
typedef typename Gt2::Has_left_category Has_left_category; using Has_left_category = typename Gt2::Has_left_category;
typedef typename Gt2::Has_merge_category Has_merge_category; using Has_merge_category = typename Gt2::Has_merge_category;
typedef typename Gt2::Has_do_intersect_category using Has_do_intersect_category = typename Gt2::Has_do_intersect_category;
Has_do_intersect_category;
typedef typename Arr::Left_side_category Left_side_category; using Left_side_category = typename Arr::Left_side_category;
typedef typename Arr::Bottom_side_category Bottom_side_category; using Bottom_side_category = typename Arr::Bottom_side_category;
typedef typename Arr::Top_side_category Top_side_category; using Top_side_category = typename Arr::Top_side_category;
typedef typename Arr::Right_side_category Right_side_category; using Right_side_category = typename Arr::Right_side_category;
// a side is either oblivious or open (unbounded) // a side is either oblivious or open (unbounded)
static_assert(std::is_same<Left_side_category, Arr_oblivious_side_tag>::value || static_assert(std::is_same<Left_side_category, Arr_oblivious_side_tag>::value ||
@ -132,8 +127,8 @@ public:
static_assert(std::is_same<Right_side_category, Arr_oblivious_side_tag>::value || static_assert(std::is_same<Right_side_category, Arr_oblivious_side_tag>::value ||
std::is_same<Right_side_category, Arr_open_side_tag>::value); std::is_same<Right_side_category, Arr_open_side_tag>::value);
typedef typename Arr::Halfedge_handle Halfedge_handle; using Halfedge_handle = typename Arr::Halfedge_handle;
typedef typename Arr::Vertex_handle Vertex_handle; using Vertex_handle = typename Arr::Vertex_handle;
Gps_agg_meta_traits() {} Gps_agg_meta_traits() {}
@ -152,16 +147,13 @@ 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 {
{
// Check whether the curves are already in the same arrangement, and thus // Check whether the curves are already in the same arrangement, and thus
// must be interior-disjoint // must be interior-disjoint
if (cv1.data().arr() == cv2.data().arr()) return oi; if (cv1.data().arr() == cv2.data().arr()) return oi;
typedef const std::pair<Base_point_2, Multiplicity> using Intersection_base_point = const std::pair<Base_point_2, Multiplicity>;
Intersection_base_point; using Intersection_base_result = std::variant<Intersection_base_point, Base_x_monotone_curve_2>;
typedef std::variant<Intersection_base_point, Base_x_monotone_curve_2>
Intersection_base_result;
const auto* base_traits = m_traits.m_base_traits; const auto* base_traits = m_traits.m_base_traits;
auto base_cmp_xy = base_traits->compare_xy_2_object(); auto base_cmp_xy = base_traits->compare_xy_2_object();
@ -191,8 +183,8 @@ public:
const Base_x_monotone_curve_2* overlap_cv = const Base_x_monotone_curve_2* overlap_cv =
std::get_if<Base_x_monotone_curve_2>(&xection); std::get_if<Base_x_monotone_curve_2>(&xection);
CGAL_assertion(overlap_cv != nullptr); CGAL_assertion(overlap_cv != nullptr);
unsigned int ov_bc; std::size_t ov_bc;
unsigned int ov_twin_bc; std::size_t ov_twin_bc;
if (base_cmp_endpoints(cv1) == base_cmp_endpoints(cv2)) { if (base_cmp_endpoints(cv1) == base_cmp_endpoints(cv2)) {
// cv1 and cv2 have the same directions // cv1 and cv2 have the same directions
ov_bc = cv1.data().bc() + cv2.data().bc(); ov_bc = cv1.data().bc() + cv2.data().bc();
@ -230,8 +222,7 @@ public:
Split_2(const Base_Split_2& base) : m_base_split(base) {} Split_2(const Base_Split_2& base) : m_base_split(base) {}
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 {
{
m_base_split(cv.base(), p.base(), c1.base(), c2.base()); m_base_split(cv.base(), p.base(), c1.base(), c2.base());
const Curve_data& cv_data = cv.data(); const Curve_data& cv_data = cv.data();
c1.set_data(Curve_data(cv_data.arr(), Halfedge_handle(), cv_data.bc(), c1.set_data(Curve_data(cv_data.arr(), Halfedge_handle(), cv_data.bc(),
@ -259,8 +250,7 @@ public:
* \param cv The curve. * \param cv The curve.
* \return The left endpoint. * \return The left endpoint.
*/ */
Point_2 operator()(const X_monotone_curve_2 & cv) const Point_2 operator()(const X_monotone_curve_2 & cv) const {
{
if (cv.data().halfedge() == Halfedge_handle()) if (cv.data().halfedge() == Halfedge_handle())
return (Point_2(m_base(cv.base()))); return (Point_2(m_base(cv.base())));
@ -272,8 +262,7 @@ public:
}; };
/*! Get a Construct_min_vertex_2 functor object. */ /*! Get 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(this->m_base_traits-> return Construct_min_vertex_2(this->m_base_traits->
construct_min_vertex_2_object()); construct_min_vertex_2_object());
} }
@ -285,15 +274,14 @@ public:
public: public:
Construct_max_vertex_2(const Base_Construct_max_vertex_2& base) : Construct_max_vertex_2(const Base_Construct_max_vertex_2& base) :
m_base(base) m_base(base)
{} {}
/*! Obtain the right endpoint of the x-monotone curve (segment). /*! Obtain the right endpoint of the x-monotone curve (segment).
* \param cv The curve. * \param cv The curve.
* \return The right endpoint. * \return The right endpoint.
*/ */
Point_2 operator()(const X_monotone_curve_2& cv) const Point_2 operator()(const X_monotone_curve_2& cv) const {
{
if (cv.data().halfedge() == Halfedge_handle()) if (cv.data().halfedge() == Halfedge_handle())
return (Point_2(m_base(cv.base()))); return (Point_2(m_base(cv.base())));
@ -304,8 +292,7 @@ public:
}; };
/*! Get a Construct_min_vertex_2 functor object. */ /*! Get a Construct_min_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(this->m_base_traits-> return Construct_max_vertex_2(this->m_base_traits->
construct_max_vertex_2_object()); construct_max_vertex_2_object());
} }
@ -321,8 +308,7 @@ public:
* \param cv The curve. * \param cv The curve.
* \return The left endpoint. * \return The left endpoint.
*/ */
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 Point_data& inf1 = p1.data(); const Point_data& inf1 = p1.data();
const Point_data& inf2 = p2.data(); const Point_data& inf2 = p2.data();
@ -390,8 +376,7 @@ public:
}; };
/*! Obtain a Construct_min_vertex_2 functor object. */ /*! Obtain a Construct_min_vertex_2 functor object. */
Compare_y_near_boundary_2 compare_y_near_boundary_2_object() const Compare_y_near_boundary_2 compare_y_near_boundary_2_object() const {
{
return Compare_y_near_boundary_2(this->m_base_traits-> return Compare_y_near_boundary_2(this->m_base_traits->
compare_y_near_boundary_2_object() compare_y_near_boundary_2_object()
); );
@ -429,8 +414,7 @@ public:
}; };
/*! Obtain a Construct_min_vertex_2 functor object. */ /*! Obtain a Construct_min_vertex_2 functor object. */
Parameter_space_in_y_2 parameter_space_in_y_2_object() const Parameter_space_in_y_2 parameter_space_in_y_2_object() const {
{
return Parameter_space_in_y_2(this->m_base_traits-> return Parameter_space_in_y_2(this->m_base_traits->
parameter_space_in_y_2_object()); parameter_space_in_y_2_object());
} }
@ -462,8 +446,7 @@ public:
}; };
/*! Obtain a Construct_min_vertex_2 functor object. */ /*! Obtain a Construct_min_vertex_2 functor object. */
Compare_x_near_boundary_2 compare_x_near_boundary_2_object() const Compare_x_near_boundary_2 compare_x_near_boundary_2_object() const {
{
return Compare_x_near_boundary_2(this->m_base_traits-> return Compare_x_near_boundary_2(this->m_base_traits->
compare_x_near_boundary_2_object()); compare_x_near_boundary_2_object());
} }

View File

@ -7,7 +7,7 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ophir Setter <ophir.setter@cs.tau.ac.il> // Ophir Setter <ophir.setter@cs.tau.ac.il>
#ifndef CGAL_BSO_2_GPS_AGG_OP_H #ifndef CGAL_BSO_2_GPS_AGG_OP_H
@ -39,29 +39,29 @@ namespace CGAL {
template <typename Arrangement_, typename BfsVisitor> template <typename Arrangement_, typename BfsVisitor>
class Gps_agg_op { class Gps_agg_op {
typedef Arrangement_ Arrangement_2; using Arrangement_2 = Arrangement_;
typedef BfsVisitor Bfs_visitor; using Bfs_visitor = BfsVisitor;
typedef typename Arrangement_2::Traits_adaptor_2 Geometry_traits_2; using Geometry_traits_2 = typename Arrangement_2::Traits_adaptor_2;
typedef typename Arrangement_2::Topology_traits Topology_traits; using Topology_traits = typename Arrangement_2::Topology_traits;
typedef Arrangement_2 Arr; using Arr = Arrangement_2;
typedef Geometry_traits_2 Gt2; using Gt2 = Geometry_traits_2;
typedef Topology_traits Tt; using Tt = Topology_traits;
typedef typename Gt2::Curve_const_iterator Curve_const_iterator; using Curve_const_iterator = typename Gt2::Curve_const_iterator;
typedef Gps_agg_meta_traits<Arr> Mgt2; using Mgt2 = Gps_agg_meta_traits<Arr>;
typedef typename Mgt2::Curve_data Curve_data; using Curve_data = typename Mgt2::Curve_data;
typedef typename Mgt2::X_monotone_curve_2 Meta_X_monotone_curve_2; using Meta_X_monotone_curve_2 = typename Mgt2::X_monotone_curve_2;
typedef typename Arr::Halfedge_handle Halfedge_handle; using Halfedge_handle = typename Arr::Halfedge_handle;
typedef typename Arr::Halfedge_iterator Halfedge_iterator; using Halfedge_iterator = typename Arr::Halfedge_iterator;
typedef typename Arr::Face_handle Face_handle; using Face_handle = typename Arr::Face_handle;
typedef typename Arr::Edge_iterator Edge_iterator; using Edge_iterator = typename Arr::Edge_iterator;
typedef typename Arr::Vertex_handle Vertex_handle; using Vertex_handle = typename Arr::Vertex_handle;
typedef typename Arr::Allocator Allocator; using Allocator = typename Arr::Allocator;
typedef std::pair<Arr*, std::vector<Vertex_handle> *> Arr_entry; using Arr_entry = std::pair<Arr*, std::vector<Vertex_handle> *>;
// We obtain a proper helper type from the topology traits of the arrangement. // We obtain a proper helper type from the topology traits of the arrangement.
// However, the arrangement is parametrized with the Gt2 geometry traits, // However, the arrangement is parametrized with the Gt2 geometry traits,
@ -70,21 +70,17 @@ class Gps_agg_op {
// We cannot parameterized the arrangement with the Mgt2 geometry // We cannot parameterized the arrangement with the Mgt2 geometry
// traits to start with, because it extends the curve type with arrangement // traits to start with, because it extends the curve type with arrangement
// dependent types. (It is parameterized with the arrangement type.) // dependent types. (It is parameterized with the arrangement type.)
typedef Indexed_event<Mgt2, Arr, Allocator> Event; using Event = Indexed_event<Mgt2, Arr, Allocator>;
typedef Arr_construction_subcurve<Mgt2, Event, Allocator> using Subcurve = Arr_construction_subcurve<Mgt2, Event, Allocator>;
Subcurve; using Helper_tmp = typename Tt::template Construction_helper<Event, Subcurve>;
typedef typename Tt::template Construction_helper<Event, Subcurve> using Helper = typename Helper_tmp::template rebind<Mgt2, Arr, Event, Subcurve>::other;
Helper_tmp; using Visitor = Gps_agg_op_visitor<Helper, Arr>;
typedef typename Helper_tmp::template rebind<Mgt2, Arr, Event, Subcurve>::other using Surface_sweep_2 = Gps_agg_op_surface_sweep_2<Arr, Visitor>;
Helper;
typedef Gps_agg_op_visitor<Helper, Arr> Visitor;
typedef Gps_agg_op_surface_sweep_2<Arr, Visitor> Surface_sweep_2;
typedef Unique_hash_map<Halfedge_handle, unsigned int> using Edges_hash = Unique_hash_map<Halfedge_handle, std::size_t>;
Edges_hash;
typedef Unique_hash_map<Face_handle, unsigned int> Faces_hash; using Faces_hash = Unique_hash_map<Face_handle, std::size_t>;
typedef Gps_bfs_scanner<Arr, Bfs_visitor> Bfs_scanner; using Bfs_scanner = Gps_bfs_scanner<Arr, Bfs_visitor>;
protected: protected:
Arr* m_arr; Arr* m_arr;
@ -103,17 +99,15 @@ public:
m_surface_sweep(m_traits, &m_visitor) m_surface_sweep(m_traits, &m_visitor)
{} {}
void sweep_arrangements(unsigned int lower, unsigned int upper, void sweep_arrangements(std::size_t lower, std::size_t upper,
unsigned int jump, std::vector<Arr_entry>& arr_vec) std::size_t jump, std::vector<Arr_entry>& arr_vec) {
{
std::list<Meta_X_monotone_curve_2> curves_list; std::list<Meta_X_monotone_curve_2> curves_list;
unsigned int n_inf_pgn = 0; // number of infinite polygons (arrangement std::size_t n_inf_pgn = 0; // number of infinite polygons (arrangement
// with a contained unbounded face // with a contained unbounded face
unsigned int n_pgn = 0; // number of polygons (arrangements) std::size_t n_pgn = 0; // number of polygons (arrangements)
unsigned int i;
for (i = lower; i <= upper; i += jump, ++n_pgn) { for (std::size_t i = lower; i <= upper; i += jump, ++n_pgn) {
// The BFS scan (after the loop) starts in the reference face, // The BFS scan (after the loop) starts in the reference face,
// so we count the number of polygons that contain the reference face. // so we count the number of polygons that contain the reference face.
Arr* arr = (arr_vec[i]).first; Arr* arr = (arr_vec[i]).first;

View File

@ -7,8 +7,8 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il> // Ron Wein <wein@post.tau.ac.il>
#ifndef CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H #ifndef CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H
#define CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H #define CGAL_BSO_2_GSP_AGG_OP_SURFACE_SWEEP_2_H
@ -27,34 +27,34 @@ namespace Ss2 = Surface_sweep_2;
template <typename Arrangement_, typename Visitor_> template <typename Arrangement_, typename Visitor_>
class Gps_agg_op_surface_sweep_2 : public Ss2::Surface_sweep_2<Visitor_> { class Gps_agg_op_surface_sweep_2 : public Ss2::Surface_sweep_2<Visitor_> {
public: public:
typedef Arrangement_ Arrangement_2; using Arrangement_2 = Arrangement_;
typedef Visitor_ Visitor; using Visitor = Visitor_;
typedef typename Visitor::Geometry_traits_2 Geometry_traits_2; using Geometry_traits_2 = typename Visitor::Geometry_traits_2;
typedef Arrangement_2 Arr; using Arr = Arrangement_2;
typedef Geometry_traits_2 Gt2; using Gt2 = Geometry_traits_2;
typedef typename Gt2::Point_2 Point_2; using Point_2 = typename Gt2::Point_2;
typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; using X_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
typedef typename Arr::Vertex_handle Vertex_handle; using Vertex_handle = typename Arr::Vertex_handle;
typedef typename Arr::Halfedge_handle Halfedge_handle; using Halfedge_handle = typename Arr::Halfedge_handle;
typedef std::pair<Arr*, std::vector<Vertex_handle> *> Arr_entry; using Arr_entry = std::pair<Arr*, std::vector<Vertex_handle> *>;
typedef Ss2::Surface_sweep_2<Visitor> Base; using Base = Ss2::Surface_sweep_2<Visitor>;
typedef typename Visitor::Event Event; using Event = typename Visitor::Event;
typedef typename Visitor::Subcurve Subcurve; using Subcurve = typename Visitor::Subcurve;
typedef typename Base::Event_queue_iterator EventQueueIter; using EventQueueIter = typename Base::Event_queue_iterator;
typedef typename Event::Subcurve_iterator EventCurveIter; using EventCurveIter = typename Event::Subcurve_iterator;
typedef typename Event::Attribute Attribute; using Attribute = typename Event::Attribute;
typedef std::list<Subcurve*> SubCurveList; using SubCurveList = std::list<Subcurve*>;
typedef typename SubCurveList::iterator SubCurveListIter; using SubCurveListIter = typename SubCurveList::iterator;
public: public:
/*! Constructor. /*! Constructor.
@ -73,18 +73,16 @@ public:
/*! Perform the sweep. */ /*! Perform the sweep. */
template <class CurveInputIterator> template <class CurveInputIterator>
void sweep(CurveInputIterator curves_begin, CurveInputIterator curves_end, void sweep(CurveInputIterator curves_begin, CurveInputIterator curves_end,
unsigned int lower, unsigned int upper, unsigned int jump, std::size_t lower, std::size_t upper, std::size_t jump,
std::vector<Arr_entry>& arr_vec) std::vector<Arr_entry>& arr_vec) {
{
CGAL_assertion(this->m_queue->empty() && this->m_statusLine.size() == 0); CGAL_assertion(this->m_queue->empty() && this->m_statusLine.size() == 0);
typedef Unique_hash_map<Vertex_handle, Event*> Vertices_map; using Vertices_map = Unique_hash_map<Vertex_handle, Event*>;
typedef typename Gt2::Compare_xy_2 Compare_xy_2; using Compare_xy_2 = typename Gt2::Compare_xy_2;
this->m_visitor->before_sweep(); this->m_visitor->before_sweep();
// Allocate all of the Subcurve objects as one block. // Allocate all of the Subcurve objects as one block.
this->m_num_of_subCurves = this->m_num_of_subCurves = std::distance(curves_begin, curves_end);
static_cast<unsigned int>(std::distance(curves_begin, curves_end));
if (this->m_num_of_subCurves > 0) if (this->m_num_of_subCurves > 0)
this->m_subCurves = this->m_subCurves =
this->m_subCurveAlloc.allocate(this->m_num_of_subCurves); this->m_subCurveAlloc.allocate(this->m_num_of_subCurves);
@ -95,9 +93,9 @@ public:
Vertices_map vert_map; Vertices_map vert_map;
Vertex_handle vh; Vertex_handle vh;
Vertex_handle invalid_v; Vertex_handle invalid_v;
unsigned int i = lower; std::size_t i = lower;
unsigned int n = static_cast<unsigned int>((arr_vec[i].second)->size()); auto n = (arr_vec[i].second)->size();
unsigned int j; std::size_t j;
EventQueueIter q_iter; EventQueueIter q_iter;
bool first = true; bool first = true;
Attribute event_type; Attribute event_type;
@ -135,7 +133,7 @@ public:
for (i += jump; i <= upper; i += jump) { for (i += jump; i <= upper; i += jump) {
// Merge the vertices of the other vectors into the existing queue. // Merge the vertices of the other vectors into the existing queue.
q_iter = this->m_queue->begin(); q_iter = this->m_queue->begin();
n = static_cast<unsigned int>((arr_vec[i].second)->size()); n = (arr_vec[i].second)->size();
for (j = 0; j < n && (vh = (*(arr_vec[i].second))[j]) != invalid_v; j++) { for (j = 0; j < n && (vh = (*(arr_vec[i].second))[j]) != invalid_v; j++) {
event_type = _type_of_vertex(vh); event_type = _type_of_vertex(vh);
@ -170,7 +168,7 @@ public:
// Go over all curves (which are associated with halfedges) and associate // Go over all curves (which are associated with halfedges) and associate
// them with the events we have just created. // them with the events we have just created.
unsigned int index = 0; std::size_t index = 0;
CurveInputIterator iter; CurveInputIterator iter;
Halfedge_handle he; Halfedge_handle he;
Event* e_left; Event* e_left;
@ -194,7 +192,7 @@ public:
} }
// Create the subcurve object. // Create the subcurve object.
typedef decltype(this->m_subCurveAlloc) Subcurve_alloc; using Subcurve_alloc = decltype(this->m_subCurveAlloc);
std::allocator_traits<Subcurve_alloc>::construct(this->m_subCurveAlloc, this->m_subCurves + index, std::allocator_traits<Subcurve_alloc>::construct(this->m_subCurveAlloc, this->m_subCurves + index,
this->m_masterSubcurve); this->m_masterSubcurve);
(this->m_subCurves + index)->init(*iter); (this->m_subCurves + index)->init(*iter);
@ -218,8 +216,7 @@ private:
* Check if the given vertex is an endpoint of an edge we are going * Check if the given vertex is an endpoint of an edge we are going
* to use in the sweep. * to use in the sweep.
*/ */
Attribute _type_of_vertex(Vertex_handle v) Attribute _type_of_vertex(Vertex_handle v) {
{
typename Arr::Halfedge_around_vertex_circulator first, circ; typename Arr::Halfedge_around_vertex_circulator first, circ;
circ = first = v->incident_halfedges(); circ = first = v->incident_halfedges();

View File

@ -8,7 +8,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il> // Ron Wein <wein@post.tau.ac.il>
#ifndef CGAL_BSO_2_GSP_AGG_OP_VISITOR_H #ifndef CGAL_BSO_2_GSP_AGG_OP_VISITOR_H
@ -34,30 +34,28 @@ class Gps_agg_op_base_visitor :
Visitor_> >::type> Visitor_> >::type>
{ {
public: public:
typedef Helper_ Helper; using Helper = Helper_;
typedef Arrangement_ Arrangement_2; using Arrangement_2 = Arrangement_;
typedef typename Helper::Geometry_traits_2 Geometry_traits_2; using Geometry_traits_2 = typename Helper::Geometry_traits_2;
typedef typename Helper::Event Event; using Event = typename Helper::Event;
typedef typename Helper::Subcurve Subcurve; using Subcurve = typename Helper::Subcurve;
private: private:
typedef Geometry_traits_2 Gt2; using Gt2 = Geometry_traits_2;
typedef Arrangement_2 Arr; using Arr = Arrangement_2;
typedef Gps_agg_op_base_visitor<Helper, Arr, Visitor_> using Self = Gps_agg_op_base_visitor<Helper, Arr, Visitor_>;
Self; using Visitor = typename Default::Get<Visitor_, Self>::type;
typedef typename Default::Get<Visitor_, Self>::type Visitor; using Base = Arr_construction_ss_visitor<Helper, Visitor>;
typedef Arr_construction_ss_visitor<Helper, Visitor> Base;
public: public:
typedef typename Arr::Halfedge_handle Halfedge_handle; using Halfedge_handle = typename Arr::Halfedge_handle;
typedef typename Arr::Vertex_handle Vertex_handle; using Vertex_handle = typename Arr::Vertex_handle;
typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; using X_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
typedef typename Gt2::Point_2 Point_2; using Point_2 = typename Gt2::Point_2;
typedef Unique_hash_map<Halfedge_handle, unsigned int> using Edges_hash = Unique_hash_map<Halfedge_handle, std::size_t>;
Edges_hash;
protected: protected:
Edges_hash* m_edges_hash; // maps halfedges to their BC (coundary counter) Edges_hash* m_edges_hash; // maps halfedges to their BC (coundary counter)
@ -138,29 +136,29 @@ class Gps_agg_op_visitor :
Visitor_> > Visitor_> >
{ {
public: public:
typedef Helper_ Helper; using Helper = Helper_;
typedef Arrangement_ Arrangement_2; using Arrangement_2 = Arrangement_;
typedef typename Helper::Geometry_traits_2 Geometry_traits_2; using Geometry_traits_2 = typename Helper::Geometry_traits_2;
typedef typename Helper::Event Event; using Event = typename Helper::Event;
typedef typename Helper::Subcurve Subcurve; using Subcurve = typename Helper::Subcurve;
private: private:
typedef Geometry_traits_2 Gt2; using Gt2 = Geometry_traits_2;
typedef Arrangement_2 Arr; using Arr = Arrangement_2;
typedef Gps_agg_op_visitor<Helper, Arr, Visitor_> Self; using Self = Gps_agg_op_visitor<Helper, Arr, Visitor_>;
typedef typename Default::Get<Visitor_, Self>::type Visitor; using Visitor = typename Default::Get<Visitor_, Self>::type;
typedef Gps_agg_op_base_visitor<Helper, Arr, Visitor> Base; using Base = Gps_agg_op_base_visitor<Helper, Arr, Visitor>;
public: public:
typedef typename Base::Halfedge_handle Halfedge_handle; using Halfedge_handle = typename Base::Halfedge_handle;
typedef typename Base::Vertex_handle Vertex_handle; using Vertex_handle = typename Base::Vertex_handle;
typedef typename Gt2::X_monotone_curve_2 X_monotone_curve_2; using X_monotone_curve_2 = typename Gt2::X_monotone_curve_2;
typedef typename Gt2::Point_2 Point_2; using Point_2 = typename Gt2::Point_2;
protected: protected:
unsigned int m_event_count; // The number of events so far. std::size_t m_event_count; // The number of events so far.
std::vector<Vertex_handle>* m_vertices_vec; // The vertices, sorted in std::vector<Vertex_handle>* m_vertices_vec; // The vertices, sorted in
// ascending order. // ascending order.
@ -172,15 +170,13 @@ public:
m_vertices_vec(vertices_vec) m_vertices_vec(vertices_vec)
{} {}
void before_handle_event(Event* event) void before_handle_event(Event* event) {
{
event->set_index(m_event_count); event->set_index(m_event_count);
m_event_count++; m_event_count++;
} }
virtual Halfedge_handle virtual Halfedge_handle
insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) insert_in_face_interior(const X_monotone_curve_2& cv, Subcurve* sc) {
{
Halfedge_handle res_he = Base::insert_in_face_interior(cv, sc); Halfedge_handle res_he = Base::insert_in_face_interior(cv, sc);
// We now have a halfedge whose source vertex is associated with the // We now have a halfedge whose source vertex is associated with the
@ -198,8 +194,7 @@ public:
virtual Halfedge_handle insert_from_right_vertex(const X_monotone_curve_2& cv, virtual Halfedge_handle insert_from_right_vertex(const X_monotone_curve_2& cv,
Halfedge_handle he, Halfedge_handle he,
Subcurve* sc) Subcurve* sc) {
{
Halfedge_handle res_he = Base::insert_from_right_vertex(cv, he, sc); Halfedge_handle res_he = Base::insert_from_right_vertex(cv, he, sc);
// We now have a halfedge whose target vertex is associated with the // We now have a halfedge whose target vertex is associated with the
@ -213,8 +208,7 @@ public:
virtual Halfedge_handle insert_from_left_vertex(const X_monotone_curve_2& cv, virtual Halfedge_handle insert_from_left_vertex(const X_monotone_curve_2& cv,
Halfedge_handle he, Halfedge_handle he,
Subcurve* sc) Subcurve* sc) {
{
Halfedge_handle res_he = Base::insert_from_left_vertex(cv, he, sc); Halfedge_handle res_he = Base::insert_from_left_vertex(cv, he, sc);
// We now have a halfedge whose target vertex is associated with the // We now have a halfedge whose target vertex is associated with the
@ -228,13 +222,11 @@ public:
} }
private: private:
void _insert_vertex(const Event* event, Vertex_handle v) void _insert_vertex(const Event* event, Vertex_handle v) {
{ const auto index = event->index();
const unsigned int index = event->index();
if (index >= m_vertices_vec->size()) m_vertices_vec->resize(2 * (index + 1)); if (index >= m_vertices_vec->size()) m_vertices_vec->resize(2 * (index + 1));
(*m_vertices_vec)[index] = v; (*m_vertices_vec)[index] = v;
} }
}; };
} // namespace CGAL } // namespace CGAL

View File

@ -8,90 +8,84 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ophir Setter <ophir.setter@cs.tau.ac.il> // Ophir Setter <ophir.setter@cs.tau.ac.il>
#ifndef CGAL_GPS_BPS_BASE_VISITOR_H #ifndef CGAL_GPS_BPS_BASE_VISITOR_H
#define CGAL_GPS_BPS_BASE_VISITOR_H #define CGAL_GPS_BPS_BASE_VISITOR_H
#include <CGAL/license/Boolean_set_operations_2.h> #include <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Unique_hash_map.h> #include <CGAL/Unique_hash_map.h>
namespace CGAL { namespace CGAL {
//! Gps_bfs_base_visitor //! Gps_bfs_base_visitor
/*! This is a base class for all visitors that are responsible for merging /*! This is a base class for all visitors that are responsible for merging
polygon sets. * polygon sets.
We use DerivedVisitor for static polymorphism for using contained_criteria * We use DerivedVisitor for static polymorphism for using contained_criteria
which determines if we should mark the face as contained given the inside * which determines if we should mark the face as contained given the inside
count of the face. * count of the face.
*/ */
template <class Arrangement_, class DerivedVisitor> template <class Arrangement_, class DerivedVisitor>
class Gps_bfs_base_visitor class Gps_bfs_base_visitor {
{ using Arrangement = Arrangement_;
typedef Arrangement_ Arrangement; using Face_iterator = typename Arrangement::Face_iterator;
typedef typename Arrangement::Face_iterator Face_iterator; using Halfedge_iterator = typename Arrangement::Halfedge_iterator;
typedef typename Arrangement::Halfedge_iterator Halfedge_iterator;
public: public:
typedef Unique_hash_map<Halfedge_iterator, unsigned int> Edges_hash; using Edges_hash = Unique_hash_map<Halfedge_iterator, std::size_t>;
typedef Unique_hash_map<Face_iterator, unsigned int> Faces_hash; using Faces_hash = Unique_hash_map<Face_iterator, std::size_t>;
protected: protected:
Edges_hash* m_edges_hash; Edges_hash* m_edges_hash;
Faces_hash* m_faces_hash; Faces_hash* m_faces_hash;
unsigned int m_num_of_polygons; // number of polygons std::size_t m_num_of_polygons; // number of polygons
public: public:
Gps_bfs_base_visitor(Edges_hash* edges_hash, Gps_bfs_base_visitor(Edges_hash* edges_hash,
Faces_hash* faces_hash, Faces_hash* faces_hash,
unsigned int n_pgn): std::size_t n_pgn):
m_edges_hash(edges_hash), m_edges_hash(edges_hash),
m_faces_hash(faces_hash), m_faces_hash(faces_hash),
m_num_of_polygons(n_pgn) m_num_of_polygons(n_pgn)
{} {}
//! discovered_face
//! discovered_face /*! discovered_face is called by Gps_bfs_scanner when it reveals a new face
/*! discovered_face is called by Gps_bfs_scanner when it reveals a new face * during a BFS scan. In the BFS traversal we are going from old_face to
during a BFS scan. In the BFS traversal we are going from old_face to * new_face through the half-edge he.
new_face through the half-edge he. * \param old_face The face that was already revealed
\param old_face The face that was already revealed * \param new_face The face that we have just now revealed
\param new_face The face that we have just now revealed * \param he The half-edge that is used to traverse between them.
\param he The half-edge that is used to traverse between them. */
*/
void discovered_face(Face_iterator old_face, void discovered_face(Face_iterator old_face,
Face_iterator new_face, Face_iterator new_face,
Halfedge_iterator he) Halfedge_iterator he) {
{ std::size_t ic = compute_ic(old_face, new_face, he);
unsigned int ic = compute_ic(old_face, new_face, he);
if (static_cast<DerivedVisitor*>(this)->contained_criteria(ic)) if (static_cast<DerivedVisitor*>(this)->contained_criteria(ic))
new_face->set_contained(true); new_face->set_contained(true);
} }
// mark the unbounded_face (true iff contained) // mark the unbounded_face (true iff contained)
void visit_ubf(Face_iterator ubf, unsigned int ubf_ic) void visit_ubf(Face_iterator ubf, std::size_t ubf_ic) {
{
CGAL_assertion(ubf->is_unbounded()); CGAL_assertion(ubf->is_unbounded());
if(static_cast<DerivedVisitor*>(this)->contained_criteria(ubf_ic)) if (static_cast<DerivedVisitor*>(this)->contained_criteria(ubf_ic))
ubf->set_contained(true); ubf->set_contained(true);
} }
protected: protected:
// compute the inside count of a face // compute the inside count of a face
unsigned int compute_ic(Face_iterator f1, std::size_t compute_ic(Face_iterator f1,
Face_iterator f2, Face_iterator f2,
Halfedge_iterator he) Halfedge_iterator he) {
{
CGAL_assertion(m_edges_hash->is_defined(he) && CGAL_assertion(m_edges_hash->is_defined(he) &&
m_edges_hash->is_defined(he->twin()) && m_edges_hash->is_defined(he->twin()) &&
m_faces_hash->is_defined(f1) && m_faces_hash->is_defined(f1) &&
!m_faces_hash->is_defined(f2)); !m_faces_hash->is_defined(f2));
unsigned int ic_f2 = std::size_t ic_f2 =
(*m_faces_hash)[f1] - (*m_edges_hash)[he] + (*m_edges_hash)[he->twin()]; (*m_faces_hash)[f1] - (*m_edges_hash)[he] + (*m_edges_hash)[he->twin()];
(*m_faces_hash)[f2] = ic_f2; (*m_faces_hash)[f2] = ic_f2;

View File

@ -9,57 +9,49 @@
// //
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ophir Setter <ophir.setter@cs.tau.ac.il> // Ophir Setter <ophir.setter@cs.tau.ac.il>
#ifndef CGAL_GPS_BFS_INTERSECTION_VISITOR_H #ifndef CGAL_GPS_BFS_INTERSECTION_VISITOR_H
#define CGAL_GPS_BFS_INTERSECTION_VISITOR_H #define CGAL_GPS_BFS_INTERSECTION_VISITOR_H
#include <CGAL/license/Boolean_set_operations_2.h> #include <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_base_visitor.h> #include <CGAL/Boolean_set_operations_2/Gps_bfs_base_visitor.h>
namespace CGAL { namespace CGAL {
template <class Arrangement_> template <class Arrangement_>
class Gps_bfs_intersection_visitor : class Gps_bfs_intersection_visitor :
public Gps_bfs_base_visitor<Arrangement_, Gps_bfs_intersection_visitor<Arrangement_> > public Gps_bfs_base_visitor<Arrangement_, Gps_bfs_intersection_visitor<Arrangement_>> {
{ using Arrangement = Arrangement_;
typedef Arrangement_ Arrangement; using Face_iterator = typename Arrangement::Face_iterator;
typedef typename Arrangement::Face_iterator Face_iterator; using Halfedge_iterator = typename Arrangement::Halfedge_iterator;
typedef typename Arrangement::Halfedge_iterator Halfedge_iterator; using Self = Gps_bfs_intersection_visitor<Arrangement>;
typedef Gps_bfs_intersection_visitor<Arrangement> Self; using Base = Gps_bfs_base_visitor<Arrangement, Self>;
typedef Gps_bfs_base_visitor<Arrangement, Self> Base; using Edges_hash = typename Base::Edges_hash;
typedef typename Base::Edges_hash Edges_hash; using Faces_hash = typename Base::Faces_hash;
typedef typename Base::Faces_hash Faces_hash;
public: public:
Gps_bfs_intersection_visitor(Edges_hash* edges_hash, Gps_bfs_intersection_visitor(Edges_hash* edges_hash,
Faces_hash* faces_hash, Faces_hash* faces_hash,
unsigned int n_polygons): std::size_t n_polygons):
Base(edges_hash, faces_hash, n_polygons) Base(edges_hash, faces_hash, n_polygons)
{} {}
//! contained_criteria
//! contained_criteria /*! contained_criteria is used to the determine if the face which has
/*! contained_criteria is used to the determine if the face which has * inside count should be marked as contained.
inside count should be marked as contained. * \param ic the inner count of the talked-about face.
\param ic the inner count of the talked-about face. * \return true if the face of ic, otherwise false.
\return true if the face of ic, otherwise false. */
*/ bool contained_criteria(std::size_t ic) {
bool contained_criteria(unsigned int ic)
{
// intersection means that all polygons contain the face. // intersection means that all polygons contain the face.
CGAL_assertion(ic <= this->m_num_of_polygons); CGAL_assertion(ic <= this->m_num_of_polygons);
return (ic == this->m_num_of_polygons); return (ic == this->m_num_of_polygons);
} }
void after_scan(Arrangement&) void after_scan(Arrangement&) {}
{}
}; };
} //namespace CGAL } //namespace CGAL

View File

@ -8,52 +8,46 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ophir Setter <ophir.setter@cs.tau.ac.il> // Ophir Setter <ophir.setter@cs.tau.ac.il>
#ifndef CGAL_GPS_BFS_JOIN_VISITOR_H #ifndef CGAL_GPS_BFS_JOIN_VISITOR_H
#define CGAL_GPS_BFS_JOIN_VISITOR_H #define CGAL_GPS_BFS_JOIN_VISITOR_H
#include <CGAL/license/Boolean_set_operations_2.h> #include <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_base_visitor.h> #include <CGAL/Boolean_set_operations_2/Gps_bfs_base_visitor.h>
namespace CGAL { namespace CGAL {
template <class Arrangement_> template <typename Arrangement_>
class Gps_bfs_join_visitor : class Gps_bfs_join_visitor :
public Gps_bfs_base_visitor<Arrangement_, Gps_bfs_join_visitor<Arrangement_> > public Gps_bfs_base_visitor<Arrangement_, Gps_bfs_join_visitor<Arrangement_>> {
{ using Arrangement = Arrangement_;
typedef Arrangement_ Arrangement; using Face_iterator = typename Arrangement::Face_iterator;
typedef typename Arrangement::Face_iterator Face_iterator; using Halfedge_iterator = typename Arrangement::Halfedge_iterator;
typedef typename Arrangement::Halfedge_iterator Halfedge_iterator; using Self = Gps_bfs_join_visitor<Arrangement>;
typedef Gps_bfs_join_visitor<Arrangement> Self; using Base = Gps_bfs_base_visitor<Arrangement, Self>;
typedef Gps_bfs_base_visitor<Arrangement, Self> Base; using Edges_hash = typename Base::Edges_hash;
typedef typename Base::Edges_hash Edges_hash; using Faces_hash = typename Base::Faces_hash;
typedef typename Base::Faces_hash Faces_hash;
public: public:
Gps_bfs_join_visitor(Edges_hash* edges_hash, Faces_hash* faces_hash, std::size_t n_pgn):
Gps_bfs_join_visitor(Edges_hash* edges_hash, Faces_hash* faces_hash, unsigned int n_pgn):
Base(edges_hash, faces_hash, n_pgn) Base(edges_hash, faces_hash, n_pgn)
{} {}
//! contained_criteria //! contained_criteria
/*! contained_criteria is used to the determine if the face which has /*! contained_criteria is used to the determine if the face which has
inside count should be marked as contained. * inside count should be marked as contained.
\param ic the inner count of the talked-about face. * \param ic the inner count of the talked-about face.
\return true if the face of ic, otherwise false. * \return true if the face of ic, otherwise false.
*/ */
bool contained_criteria(unsigned int ic) bool contained_criteria(std::size_t ic) {
{
// at least one polygon contains the face. // at least one polygon contains the face.
return (ic > 0); return (ic > 0);
} }
void after_scan(Arrangement&) void after_scan(Arrangement&) {}
{}
}; };
} //namespace CGAL } //namespace CGAL

View File

@ -8,8 +8,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ophir Setter <ophir.setter@cs.tau.ac.il> // Ophir Setter <ophir.setter@cs.tau.ac.il>
#ifndef CGAL_GPS_BFS_XOR_VISITOR_H #ifndef CGAL_GPS_BFS_XOR_VISITOR_H
#define CGAL_GPS_BFS_XOR_VISITOR_H #define CGAL_GPS_BFS_XOR_VISITOR_H
@ -23,43 +23,39 @@ namespace CGAL {
template <class Arrangement_> template <class Arrangement_>
class Gps_bfs_xor_visitor : class Gps_bfs_xor_visitor :
public Gps_bfs_base_visitor<Arrangement_, Gps_bfs_xor_visitor<Arrangement_> > public Gps_bfs_base_visitor<Arrangement_, Gps_bfs_xor_visitor<Arrangement_>> {
{ using Arrangement = Arrangement_;
typedef Arrangement_ Arrangement; using Face_iterator = typename Arrangement::Face_iterator;
typedef typename Arrangement::Face_iterator Face_iterator; using Halfedge_iterator = typename Arrangement::Halfedge_iterator;
typedef typename Arrangement::Halfedge_iterator Halfedge_iterator; using Self = Gps_bfs_xor_visitor<Arrangement>;
typedef Gps_bfs_xor_visitor<Arrangement> Self; using Base = Gps_bfs_base_visitor<Arrangement, Self>;
typedef Gps_bfs_base_visitor<Arrangement, Self> Base; using Edges_hash = typename Base::Edges_hash;
typedef typename Base::Edges_hash Edges_hash; using Faces_hash = typename Base::Faces_hash;
typedef typename Base::Faces_hash Faces_hash;
public: public:
Gps_bfs_xor_visitor(Edges_hash* edges_hash, Faces_hash* faces_hash, Gps_bfs_xor_visitor(Edges_hash* edges_hash, Faces_hash* faces_hash,
unsigned int n_pgn) : std::size_t n_pgn) :
Base(edges_hash, faces_hash, n_pgn) Base(edges_hash, faces_hash, n_pgn)
{} {}
//! contained_criteria //! contained_criteria
/*! contained_criteria is used to the determine if the face which has /*! contained_criteria is used to the determine if the face which has
inside count should be marked as contained. inside count should be marked as contained.
\param ic the inner count of the talked-about face. \param ic the inner count of the talked-about face.
\return true if the face of ic, otherwise false. \return true if the face of ic, otherwise false.
*/ */
bool contained_criteria(unsigned int ic) bool contained_criteria(std::size_t ic) {
{
// xor means odd number of polygons. // xor means odd number of polygons.
return (ic % 2) == 1; return (ic % 2) == 1;
} }
//! after_scan postprocessing after bfs scan. //! after_scan postprocessing after bfs scan.
/*! The function fixes some of the curves, to be in the same direction as the /*! The function fixes some of the curves, to be in the same direction as the
half-edges. half-edges.
\param arr The given arrangement. \param arr The given arrangement.
*/ */
void after_scan(Arrangement& arr) void after_scan(Arrangement& arr) {
{
typedef typename Arrangement::Geometry_traits_2 Traits; typedef typename Arrangement::Geometry_traits_2 Traits;
typedef typename Traits::Compare_endpoints_xy_2 Compare_endpoints_xy_2; typedef typename Traits::Compare_endpoints_xy_2 Compare_endpoints_xy_2;
typedef typename Traits::Construct_opposite_2 Construct_opposite_2; typedef typename Traits::Construct_opposite_2 Construct_opposite_2;
@ -71,23 +67,19 @@ public:
tr.compare_endpoints_xy_2_object(); tr.compare_endpoints_xy_2_object();
Construct_opposite_2 ctr_opp = tr.construct_opposite_2_object(); Construct_opposite_2 ctr_opp = tr.construct_opposite_2_object();
for(Edge_iterator eit = arr.edges_begin(); for (auto eit = arr.edges_begin(); eit != arr.edges_end(); ++eit) {
eit != arr.edges_end(); Halfedge_iterator he = eit;
++eit)
{
Halfedge_iterator he = eit;
const X_monotone_curve_2& cv = he->curve(); const X_monotone_curve_2& cv = he->curve();
const bool is_cont = he->face()->contained(); const bool is_cont = he->face()->contained();
const Comparison_result he_res = const Comparison_result he_res =
((Arr_halfedge_direction)he->direction() == ARR_LEFT_TO_RIGHT) ? ((Arr_halfedge_direction)he->direction() == ARR_LEFT_TO_RIGHT) ?
SMALLER : LARGER; SMALLER : LARGER;
const bool has_same_dir = (cmp_endpoints(cv) == he_res); const bool has_same_dir = (cmp_endpoints(cv) == he_res);
if ((is_cont && !has_same_dir) || (!is_cont && has_same_dir)) if ((is_cont && !has_same_dir) || (!is_cont && has_same_dir))
arr.modify_edge(he, ctr_opp(cv)); arr.modify_edge(he, ctr_opp(cv));
} }
} }
}; };
} //namespace CGAL } //namespace CGAL

View File

@ -7,14 +7,13 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il>
#ifndef CGAL_GPS_MERGE_H #ifndef CGAL_GPS_MERGE_H
#define CGAL_GPS_MERGE_H #define CGAL_GPS_MERGE_H
#include <CGAL/license/Boolean_set_operations_2.h> #include <CGAL/license/Boolean_set_operations_2.h>
#include <CGAL/Boolean_set_operations_2/Gps_agg_op.h> #include <CGAL/Boolean_set_operations_2/Gps_agg_op.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_join_visitor.h> #include <CGAL/Boolean_set_operations_2/Gps_bfs_join_visitor.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_xor_visitor.h> #include <CGAL/Boolean_set_operations_2/Gps_bfs_xor_visitor.h>
@ -23,50 +22,42 @@
namespace CGAL { namespace CGAL {
/*! /*! \file Gps_merge.h
\file Gps_merge.h * \brief This file contains classes that are responsible for merging
\brief This file contains classes that are responsible for merging * two sets of polygons in the divide-and-conquer algorithm.
two sets of polygons in the divide-and-conquer algorithm. * The file contains 3 mergers: Join_merge, Intersection_merge and
The file contains 3 mergers: Join_merge, Intersection_merge and * Xor_merge. Join_merge is used when we want to merge the two sets,
Xor_merge. Join_merge is used when we want to merge the two sets, * Intersection_merge is used for intersection, and Xor_merge is used
Intersection_merge is used for intersection, and Xor_merge is used * for symmetric difference.
for symmetric difference. */
*/
//! Base_merge //! Base_merge
/*! Base_merge is the base class for all merger classes. /*! Base_merge is the base class for all merger classes.
All merges used BFS algorithm with a different visitor when discovering * All merges used BFS algorithm with a different visitor when discovering
a new face. * a new face.
*/ */
template <class Arrangement_, class Visitor_> template <typename Arrangement_, typename Visitor_>
class Base_merge class Base_merge {
{ using Arrangement_2 = Arrangement_;
typedef Arrangement_ Arrangement_2; using Visitor = Visitor_;
typedef Visitor_ Visitor; using Vertex_handle = typename Arrangement_2::Vertex_handle;
typedef typename Arrangement_2::Vertex_handle Vertex_handle; using Arr_entry = std::pair<Arrangement_2*, std::vector<Vertex_handle>*>;
typedef std::pair<Arrangement_2 *,
std::vector<Vertex_handle> *> Arr_entry;
public: public:
void operator()(unsigned int i, void operator()(std::size_t i, std::size_t j, std::size_t jump,
unsigned int j, std::vector<Arr_entry>& arr_vec) {
unsigned int jump, if (i == j) return;
std::vector<Arr_entry>& arr_vec)
{
if(i==j)
return;
const typename Arrangement_2::Geometry_traits_2 * tr = const typename Arrangement_2::Geometry_traits_2* tr =
arr_vec[i].first->geometry_traits(); arr_vec[i].first->geometry_traits();
Arrangement_2 *res = new Arrangement_2(tr); Arrangement_2* res = new Arrangement_2(tr);
std::vector<Vertex_handle> *verts = new std::vector<Vertex_handle>; std::vector<Vertex_handle>* verts = new std::vector<Vertex_handle>;
Gps_agg_op<Arrangement_2, Visitor> Gps_agg_op<Arrangement_2, Visitor>
agg_op(*res, *verts, *(res->traits_adaptor())); agg_op(*res, *verts, *(res->traits_adaptor()));
agg_op.sweep_arrangements(i, j, jump, arr_vec); agg_op.sweep_arrangements(i, j, jump, arr_vec);
for(unsigned int count=i; count<=j; count+=jump) for (std::size_t count = i; count <= j; count += jump) {
{
delete (arr_vec[count].first); delete (arr_vec[count].first);
delete (arr_vec[count].second); delete (arr_vec[count].second);
} }
@ -74,37 +65,31 @@ public:
arr_vec[i].first = res; arr_vec[i].first = res;
arr_vec[i].second = verts; arr_vec[i].second = verts;
} }
}; };
//! Join_merge //! Join_merge
/*! Join_merge is used to join two sets of polygons together in the D&C /*! Join_merge is used to join two sets of polygons together in the D&C
algorithm. It is a base merge with a visitor that joins faces. * algorithm. It is a base merge with a visitor that joins faces.
*/ */
template <class Arrangement_> template <class Arrangement_>
class Join_merge : public Base_merge<Arrangement_, class Join_merge : public Base_merge<Arrangement_, Gps_bfs_join_visitor<Arrangement_>>
Gps_bfs_join_visitor<Arrangement_> >
{}; {};
//! Intersection_merge //! Intersection_merge
/*! Intersection_merge is used to merge two sets of polygons creating their /*! Intersection_merge is used to merge two sets of polygons creating their
intersection. * intersection.
*/ */
template <class Arrangement_> template <class Arrangement_>
class Intersection_merge : public Base_merge<Arrangement_, class Intersection_merge : public Base_merge<Arrangement_, Gps_bfs_intersection_visitor<Arrangement_>>
Gps_bfs_intersection_visitor<Arrangement_> >
{}; {};
//! Xor_merge //! Xor_merge
/*! Xor_merge is used to merge two sets of polygons creating their /*! Xor_merge is used to merge two sets of polygons creating their
symmetric difference. * symmetric difference.
*/ */
template <class Arrangement_> template <class Arrangement_>
class Xor_merge : public Base_merge<Arrangement_, class Xor_merge : public Base_merge<Arrangement_, Gps_bfs_xor_visitor<Arrangement_>>
Gps_bfs_xor_visitor<Arrangement_> > {};
{
};
} //namespace CGAL } //namespace CGAL

View File

@ -7,9 +7,9 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ophir Setter <ophir.setter@cs.tau.ac.il> // Ophir Setter <ophir.setter@cs.tau.ac.il>
// Guy Zucker <guyzucke@post.tau.ac.il> // Guy Zucker <guyzucke@post.tau.ac.il>
#ifndef CGAL_GPS_ON_SURFACE_BASE_2_H #ifndef CGAL_GPS_ON_SURFACE_BASE_2_H
@ -131,7 +131,7 @@ protected:
Aos_2* m_arr; Aos_2* m_arr;
public: public:
// default constructor // constructs default
Gps_on_surface_base_2() : Gps_on_surface_base_2() :
m_traits(new Traits_2()), m_traits(new Traits_2()),
m_traits_adaptor(*m_traits), m_traits_adaptor(*m_traits),
@ -140,7 +140,7 @@ public:
{} {}
// constructor with traits object // constructs with traits object
Gps_on_surface_base_2(const Traits_2& tr) : Gps_on_surface_base_2(const Traits_2& tr) :
m_traits(&tr), m_traits(&tr),
m_traits_adaptor(*m_traits), m_traits_adaptor(*m_traits),
@ -148,7 +148,7 @@ public:
m_arr(new Aos_2(m_traits)) m_arr(new Aos_2(m_traits))
{} {}
// Copy constructor // copy constructs
Gps_on_surface_base_2(const Self& ps) : Gps_on_surface_base_2(const Self& ps) :
m_traits(new Traits_2(*(ps.m_traits))), m_traits(new Traits_2(*(ps.m_traits))),
m_traits_adaptor(*m_traits), m_traits_adaptor(*m_traits),
@ -156,7 +156,7 @@ public:
m_arr(new Aos_2(*(ps.m_arr))) m_arr(new Aos_2(*(ps.m_arr)))
{} {}
// Assignment operator // assigns
Gps_on_surface_base_2& operator=(const Self& ps) { Gps_on_surface_base_2& operator=(const Self& ps) {
if (this == &ps) return (*this); if (this == &ps) return (*this);
@ -169,7 +169,7 @@ public:
return (*this); return (*this);
} }
// Constructor // constructs
explicit Gps_on_surface_base_2(const Polygon_2& pgn) : explicit Gps_on_surface_base_2(const Polygon_2& pgn) :
m_traits(new Traits_2()), m_traits(new Traits_2()),
m_traits_adaptor(*m_traits), m_traits_adaptor(*m_traits),
@ -179,7 +179,7 @@ public:
_insert(pgn, *m_arr); _insert(pgn, *m_arr);
} }
// Constructor // constructs
explicit Gps_on_surface_base_2(const Polygon_2& pgn, const Traits_2& tr) : explicit Gps_on_surface_base_2(const Polygon_2& pgn, const Traits_2& tr) :
m_traits(&tr), m_traits(&tr),
m_traits_adaptor(*m_traits), m_traits_adaptor(*m_traits),
@ -189,7 +189,7 @@ public:
_insert(pgn, *m_arr); _insert(pgn, *m_arr);
} }
// Constructor // constructs
explicit Gps_on_surface_base_2(const Polygon_with_holes_2& pgn_with_holes) : explicit Gps_on_surface_base_2(const Polygon_with_holes_2& pgn_with_holes) :
m_traits(new Traits_2()), m_traits(new Traits_2()),
m_traits_adaptor(*m_traits), m_traits_adaptor(*m_traits),
@ -199,7 +199,7 @@ public:
_insert(pgn_with_holes, *m_arr); _insert(pgn_with_holes, *m_arr);
} }
// Constructor // constructs
explicit Gps_on_surface_base_2(const Polygon_with_holes_2& pgn_with_holes, explicit Gps_on_surface_base_2(const Polygon_with_holes_2& pgn_with_holes,
const Traits_2& tr) : const Traits_2& tr) :
m_traits(&tr), m_traits(&tr),
@ -211,14 +211,15 @@ public:
} }
protected: protected:
Gps_on_surface_base_2(Aos_2* arr) : m_traits(new Traits_2()), Gps_on_surface_base_2(Aos_2* arr) :
m_traits_adaptor(*m_traits), m_traits(new Traits_2()),
m_traits_owner(true), m_traits_adaptor(*m_traits),
m_arr(arr) m_traits_owner(true),
m_arr(arr)
{} {}
public: public:
//destructor // destructs
virtual ~Gps_on_surface_base_2() { virtual ~Gps_on_surface_base_2() {
delete m_arr; delete m_arr;
@ -241,25 +242,25 @@ public:
gps.polygons_with_holes(oi); gps.polygons_with_holes(oi);
} }
// insert a simple polygon // inserts a simple polygon
void insert(const Polygon_2& pgn) { void insert(const Polygon_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_insert(pgn, *m_arr); _insert(pgn, *m_arr);
} }
// insert a polygon with holes // inserts a polygon with holes
void insert(const Polygon_with_holes_2& pgn_with_holes) { void insert(const Polygon_with_holes_2& pgn_with_holes) {
ValidationPolicy::is_valid(pgn_with_holes, *m_traits); ValidationPolicy::is_valid(pgn_with_holes, *m_traits);
_insert(pgn_with_holes, *m_arr); _insert(pgn_with_holes, *m_arr);
} }
// insert a range of polygons that can be either simple polygons // inserts a range of polygons that can be either simple polygons
// or polygons with holes // or polygons with holes
// precondition: the polygons are disjoint and simple // precondition: the polygons are disjoint and simple
template <typename PolygonIterator> template <typename PolygonIterator>
void insert(PolygonIterator pgn_begin, PolygonIterator pgn_end); void insert(PolygonIterator pgn_begin, PolygonIterator pgn_end);
// insert two ranges of : the first one for simple polygons, // inserts two ranges of : the first one for simple polygons,
// the second one for polygons with holes // the second one for polygons with holes
// precondition: the first range is disjoint simple polygons // precondition: the first range is disjoint simple polygons
// the second range is disjoint polygons with holes // the second range is disjoint polygons with holes
@ -268,21 +269,21 @@ public:
PolygonWithHolesIterator pgn_with_holes_begin, PolygonWithHolesIterator pgn_with_holes_begin,
PolygonWithHolesIterator pgn_with_holes_end); PolygonWithHolesIterator pgn_with_holes_end);
// test for intersection with a simple polygon // tests for intersection with a simple polygon
bool do_intersect(const Polygon_2& pgn) const { bool do_intersect(const Polygon_2& pgn) const {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
Self other(pgn, *m_traits); Self other(pgn, *m_traits);
return do_intersect(other); return do_intersect(other);
} }
// test for intersection with a polygon with holes // tests for intersection with a polygon with holes
bool do_intersect(const Polygon_with_holes_2& pgn_with_holes) const { bool do_intersect(const Polygon_with_holes_2& pgn_with_holes) const {
ValidationPolicy::is_valid(pgn_with_holes, *m_traits); ValidationPolicy::is_valid(pgn_with_holes, *m_traits);
Self other(pgn_with_holes, *m_traits); Self other(pgn_with_holes, *m_traits);
return do_intersect(other); return do_intersect(other);
} }
//test for intersection with another Gps_on_surface_base_2 object // tests for intersection with another Gps_on_surface_base_2 object
bool do_intersect(const Self& other) const { bool do_intersect(const Self& other) const {
if (this->is_empty() || other.is_empty()) return false; if (this->is_empty() || other.is_empty()) return false;
if (this->is_plane() || other.is_plane()) return true; if (this->is_plane() || other.is_plane()) return true;
@ -292,19 +293,19 @@ public:
return func.found_reg_intersection(); return func.found_reg_intersection();
} }
// intersection with a simple polygon // intersects with a simple polygon
void intersection(const Polygon_2& pgn) { void intersection(const Polygon_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_intersection(pgn); _intersection(pgn);
} }
// intersection with a polygon with holes // intersects with a polygon with holes
void intersection(const Polygon_with_holes_2& pgn) { void intersection(const Polygon_with_holes_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_intersection(pgn); _intersection(pgn);
} }
// intersection with another Gps_on_surface_base_2 object // intersects with another Gps_on_surface_base_2 object
void intersection(const Self& other) { _intersection(other); } void intersection(const Self& other) { _intersection(other); }
void intersection(const Self& gps1, const Self& gps2) { void intersection(const Self& gps1, const Self& gps2) {
@ -312,19 +313,19 @@ public:
_intersection(*(gps1.m_arr), *(gps2.m_arr), *(this->m_arr)); _intersection(*(gps1.m_arr), *(gps2.m_arr), *(this->m_arr));
} }
// join with a simple polygon // joins with a simple polygon
void join(const Polygon_2& pgn) { void join(const Polygon_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_join(pgn); _join(pgn);
} }
// join with a polygon with holes // joins with a polygon with holes
void join(const Polygon_with_holes_2& pgn) { void join(const Polygon_with_holes_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_join(pgn); _join(pgn);
} }
//join with another Gps_on_surface_base_2 object // joins with another Gps_on_surface_base_2 object
void join(const Self& other) { _join(other); } void join(const Self& other) { _join(other); }
void join(const Self& gps1, const Self& gps2) { void join(const Self& gps1, const Self& gps2) {
@ -332,19 +333,19 @@ public:
_join(*(gps1.m_arr), *(gps2.m_arr), *(this->m_arr)); _join(*(gps1.m_arr), *(gps2.m_arr), *(this->m_arr));
} }
// difference with a simple polygon // computes the difference with a simple polygon
void difference(const Polygon_2& pgn) { void difference(const Polygon_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_difference(pgn); _difference(pgn);
} }
// difference with a polygon with holes // computes the difference with a polygon with holes
void difference(const Polygon_with_holes_2& pgn) { void difference(const Polygon_with_holes_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_difference(pgn); _difference(pgn);
} }
//difference with another Gps_on_surface_base_2 object // computes the difference with another Gps_on_surface_base_2 object
void difference(const Self& other) { _difference(other); } void difference(const Self& other) { _difference(other); }
void difference(const Self& gps1, const Self& gps2) { void difference(const Self& gps1, const Self& gps2) {
@ -352,19 +353,19 @@ public:
_difference(*(gps1.m_arr), *(gps2.m_arr), *(this->m_arr)); _difference(*(gps1.m_arr), *(gps2.m_arr), *(this->m_arr));
} }
// symmetric_difference with a simple polygon // computes the symmetric_difference with a simple polygon
void symmetric_difference(const Polygon_2& pgn) { void symmetric_difference(const Polygon_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_symmetric_difference(pgn); _symmetric_difference(pgn);
} }
// symmetric_difference with a polygon with holes // computes the symmetric_difference with a polygon with holes
void symmetric_difference(const Polygon_with_holes_2& pgn) { void symmetric_difference(const Polygon_with_holes_2& pgn) {
ValidationPolicy::is_valid(pgn, *m_traits); ValidationPolicy::is_valid(pgn, *m_traits);
_symmetric_difference(pgn); _symmetric_difference(pgn);
} }
//symmetric_difference with another Gps_on_surface_base_2 object // computes the symmetric_difference with another Gps_on_surface_base_2 object
void symmetric_difference(const Self& other) { _symmetric_difference(other); } void symmetric_difference(const Self& other) { _symmetric_difference(other); }
void symmetric_difference(const Self& gps1, const Self& gps2) { void symmetric_difference(const Self& gps1, const Self& gps2) {
@ -414,7 +415,6 @@ public:
Face_const_iterator f; Face_const_iterator f;
if (CGAL::assign(f, obj)) { if (CGAL::assign(f, obj)) {
if (f->contained()) return ON_POSITIVE_SIDE; if (f->contained()) return ON_POSITIVE_SIDE;
return ON_NEGATIVE_SIDE ; return ON_NEGATIVE_SIDE ;
} }
return ON_ORIENTED_BOUNDARY ; return ON_ORIENTED_BOUNDARY ;
@ -433,14 +433,10 @@ public:
} }
Oriented_side oriented_side(const Self& other) const { Oriented_side oriented_side(const Self& other) const {
if (this->is_empty() || other.is_empty()) if (this->is_empty() || other.is_empty()) return ON_NEGATIVE_SIDE;
return ON_NEGATIVE_SIDE; if (this->is_plane() || other.is_plane()) return ON_POSITIVE_SIDE;
if (this->is_plane() || other.is_plane())
return ON_POSITIVE_SIDE;
Aos_2 res_arr; Aos_2 res_arr;
Gps_do_intersect_functor<Aos_2> func; Gps_do_intersect_functor<Aos_2> func;
overlay(*m_arr, *(other.m_arr), res_arr, func); overlay(*m_arr, *(other.m_arr), res_arr, func);
if (func.found_reg_intersection()) return ON_POSITIVE_SIDE; if (func.found_reg_intersection()) return ON_POSITIVE_SIDE;
@ -448,15 +444,15 @@ public:
return ON_NEGATIVE_SIDE; return ON_NEGATIVE_SIDE;
} }
// returns the location of the query point // obtains the location of the query point
bool locate(const Point_2& q, Polygon_with_holes_2& pgn) const; bool locate(const Point_2& q, Polygon_with_holes_2& pgn) const;
/*! Obtain a const reference to the underlying arrangement /*! obtains a const reference to the underlying arrangement
* \return the underlying arrangement. * \return the underlying arrangement.
*/ */
const Aos_2& arrangement() const { return *m_arr; } const Aos_2& arrangement() const { return *m_arr; }
/*! Obtain a reference to the underlying arrangement /*! obtains a reference to the underlying arrangement
* \return the underlying arrangement. * \return the underlying arrangement.
*/ */
Aos_2& arrangement() { return *m_arr; } Aos_2& arrangement() { return *m_arr; }
@ -486,16 +482,16 @@ protected:
} }
public: public:
/*! */ //
bool is_valid() { return _is_valid(*this->m_arr); } bool is_valid() { return _is_valid(*this->m_arr); }
// get the simple polygons, takes O(n) // obtains the simple polygons, takes O(n)
template <typename OutputIterator> template <typename OutputIterator>
OutputIterator polygons_with_holes(OutputIterator out) const; OutputIterator polygons_with_holes(OutputIterator out) const;
// test for intersection of a range of polygons // tests for intersection of a range of polygons
template <typename InputIterator> template <typename InputIterator>
bool do_intersect(InputIterator begin, InputIterator end, unsigned int k = 5) { bool do_intersect(InputIterator begin, InputIterator end, std::size_t k = 5) {
Self other(*this); Self other(*this);
other.intersection(begin, end, k); other.intersection(begin, end, k);
return (other.is_empty()); return (other.is_empty());
@ -504,32 +500,32 @@ public:
template <typename InputIterator1, typename InputIterator2> template <typename InputIterator1, typename InputIterator2>
bool do_intersect(InputIterator1 begin1, InputIterator1 end1, bool do_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
unsigned int k = 5) { std::size_t k = 5) {
Self other(*this); Self other(*this);
other.intersection(begin1, end1, begin2, end2, k); other.intersection(begin1, end1, begin2, end2, k);
return (other.is_empty()); return (other.is_empty());
} }
// join a range of polygons // joins a range of polygons
template <typename InputIterator> template <typename InputIterator>
void join(InputIterator begin, InputIterator end, unsigned int k = 5) { void join(InputIterator begin, InputIterator end, std::size_t k = 5) {
typename std::iterator_traits<InputIterator>::value_type pgn; typename std::iterator_traits<InputIterator>::value_type pgn;
this->join(begin, end, pgn, k); this->join(begin, end, pgn, k);
this->remove_redundant_edges(); this->remove_redundant_edges();
this->_reset_faces(); this->_reset_faces();
} }
// join range of simple polygons // joins a range of simple polygons
// 5 is the magic number in which we switch to a sweep-based algorithm // 5 is the magic number in which we switch to a sweep-based algorithm
// instead of a D&C algorithm. This point should be further studies, as // instead of a D&C algorithm. This point should be further studies, as
// it is hard to believe that this is the best value for all applications. // it is hard to believe that this is the best value for all applications.
template <typename InputIterator> template <typename InputIterator>
inline void join(InputIterator begin, InputIterator end, Polygon_2&, inline void join(InputIterator begin, InputIterator end, Polygon_2&,
unsigned int k = 5) { std::size_t k = 5) {
std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator itr = begin; itr != end; ++itr, ++i) { for (InputIterator itr = begin; itr != end; ++itr, ++i) {
ValidationPolicy::is_valid((*itr), *m_traits); ValidationPolicy::is_valid((*itr), *m_traits);
arr_vec[i].first = new Aos_2(m_traits); arr_vec[i].first = new Aos_2(m_traits);
@ -537,22 +533,22 @@ public:
} }
Join_merge<Aos_2> join_merge; Join_merge<Aos_2> join_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, join_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, join_merge);
//the result arrangement is at index 0 //the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
} }
//join range of polygons with holes (see previous comment about k=5). // joins a range of polygons with holes (see previous comment about k=5).
template <typename InputIterator> template <typename InputIterator>
inline void join(InputIterator begin, InputIterator end, inline void join(InputIterator begin, InputIterator end,
Polygon_with_holes_2&, unsigned int k = 5) { Polygon_with_holes_2&, std::size_t k = 5) {
std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator itr = begin; itr!=end; ++itr, ++i) { for (InputIterator itr = begin; itr!=end; ++itr, ++i) {
ValidationPolicy::is_valid((*itr), *m_traits); ValidationPolicy::is_valid((*itr), *m_traits);
arr_vec[i].first = new Aos_2(m_traits); arr_vec[i].first = new Aos_2(m_traits);
@ -560,10 +556,10 @@ public:
} }
Join_merge<Aos_2> join_merge; Join_merge<Aos_2> join_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, join_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, join_merge);
//the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
} }
@ -572,11 +568,11 @@ public:
template <typename InputIterator1, typename InputIterator2> template <typename InputIterator1, typename InputIterator2>
inline void join(InputIterator1 begin1, InputIterator1 end1, inline void join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
unsigned int k = 5) { std::size_t k = 5) {
std::vector<Arr_entry> arr_vec(std::distance(begin1, end1) + std::distance(begin2, end2) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin1, end1) + std::distance(begin2, end2) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator1 itr1 = begin1; itr1 != end1; ++itr1, ++i) { for (InputIterator1 itr1 = begin1; itr1 != end1; ++itr1, ++i) {
arr_vec[i].first = new Aos_2(m_traits); arr_vec[i].first = new Aos_2(m_traits);
@ -589,8 +585,8 @@ public:
} }
Join_merge<Aos_2> join_merge; Join_merge<Aos_2> join_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, join_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, join_merge);
// the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
@ -599,23 +595,23 @@ public:
this->_reset_faces(); this->_reset_faces();
} }
// intersect range of polygins (see previous comment about k=5). // intersects a range of polygins (see previous comment about k=5).
template <typename InputIterator> template <typename InputIterator>
inline void intersection(InputIterator begin, InputIterator end, inline void intersection(InputIterator begin, InputIterator end,
unsigned int k = 5) { std::size_t k = 5) {
typename std::iterator_traits<InputIterator>::value_type pgn; typename std::iterator_traits<InputIterator>::value_type pgn;
this->intersection(begin, end, pgn, k); this->intersection(begin, end, pgn, k);
this->remove_redundant_edges(); this->remove_redundant_edges();
this->_reset_faces(); this->_reset_faces();
} }
// intersect range of simple polygons // intersects a range of simple polygons
template <typename InputIterator> template <typename InputIterator>
inline void intersection(InputIterator begin, InputIterator end, inline void intersection(InputIterator begin, InputIterator end,
Polygon_2&, unsigned int k) { Polygon_2&, std::size_t k) {
std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator itr = begin; itr != end; ++itr, ++i) { for (InputIterator itr = begin; itr != end; ++itr, ++i) {
ValidationPolicy::is_valid((*itr), *m_traits); ValidationPolicy::is_valid((*itr), *m_traits);
@ -625,20 +621,20 @@ public:
Intersection_merge<Aos_2> intersection_merge; Intersection_merge<Aos_2> intersection_merge;
_build_sorted_vertices_vectors(arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, intersection_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, intersection_merge);
//the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
} }
// intersect range of polygons with holes // intersects a range of polygons with holes
template <typename InputIterator> template <typename InputIterator>
inline void intersection(InputIterator begin, InputIterator end, inline void intersection(InputIterator begin, InputIterator end,
Polygon_with_holes_2&, unsigned int k) { Polygon_with_holes_2&, std::size_t k) {
std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator itr = begin; itr!=end; ++itr, ++i) { for (InputIterator itr = begin; itr!=end; ++itr, ++i) {
ValidationPolicy::is_valid((*itr), *m_traits); ValidationPolicy::is_valid((*itr), *m_traits);
@ -647,10 +643,10 @@ public:
} }
Intersection_merge<Aos_2> intersection_merge; Intersection_merge<Aos_2> intersection_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, intersection_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, intersection_merge);
//the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
} }
@ -658,10 +654,10 @@ public:
template <typename InputIterator1, typename InputIterator2> template <typename InputIterator1, typename InputIterator2>
inline void intersection(InputIterator1 begin1, InputIterator1 end1, inline void intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
unsigned int k = 5) { std::size_t k = 5) {
std::vector<Arr_entry> arr_vec(std::distance(begin1, end1) + std::distance(begin2, end2) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin1, end1) + std::distance(begin2, end2) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator1 itr1 = begin1; itr1!=end1; ++itr1, ++i) { for (InputIterator1 itr1 = begin1; itr1!=end1; ++itr1, ++i) {
ValidationPolicy::is_valid(*itr1, *m_traits); ValidationPolicy::is_valid(*itr1, *m_traits);
@ -676,34 +672,34 @@ public:
} }
Intersection_merge<Aos_2> intersection_merge; Intersection_merge<Aos_2> intersection_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, intersection_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, intersection_merge);
//the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
this->remove_redundant_edges(); this->remove_redundant_edges();
this->_reset_faces(); this->_reset_faces();
} }
// symmetric_difference of a range of polygons (similar to xor) // computes the symmetric_difference of a range of polygons (similar to xor)
// (see previous comment about k=5). // (see previous comment about k=5).
template <typename InputIterator> template <typename InputIterator>
inline void symmetric_difference(InputIterator begin, InputIterator end, inline void symmetric_difference(InputIterator begin, InputIterator end,
unsigned int k = 5) { std::size_t k = 5) {
typename std::iterator_traits<InputIterator>::value_type pgn; typename std::iterator_traits<InputIterator>::value_type pgn;
this->symmetric_difference(begin, end, pgn, k); this->symmetric_difference(begin, end, pgn, k);
this->remove_redundant_edges(); this->remove_redundant_edges();
this->_reset_faces(); this->_reset_faces();
} }
// intersect range of simple polygons (see previous comment about k=5). // intersect a range of simple polygons (see previous comment about k=5).
template <typename InputIterator> template <typename InputIterator>
inline void symmetric_difference(InputIterator begin, InputIterator end, inline void symmetric_difference(InputIterator begin, InputIterator end,
Polygon_2&, unsigned int k = 5) { Polygon_2&, std::size_t k = 5) {
std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator itr = begin; itr!=end; ++itr, ++i) { for (InputIterator itr = begin; itr!=end; ++itr, ++i) {
ValidationPolicy::is_valid(*itr,*m_traits); ValidationPolicy::is_valid(*itr,*m_traits);
@ -712,33 +708,33 @@ public:
} }
Xor_merge<Aos_2> xor_merge; Xor_merge<Aos_2> xor_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, xor_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, xor_merge);
//the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
} }
//intersect range of polygons with holes (see previous comment about k=5). // intersects a range of polygons with holes (see previous comment about k=5).
template <typename InputIterator> template <typename InputIterator>
inline void symmetric_difference(InputIterator begin, InputIterator end, inline void symmetric_difference(InputIterator begin, InputIterator end,
Polygon_with_holes_2&, unsigned int k = 5) { Polygon_with_holes_2&, std::size_t k = 5) {
std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator itr = begin; itr!=end; ++itr, ++i) { for (InputIterator itr = begin; itr != end; ++itr, ++i) {
ValidationPolicy::is_valid(*itr,*m_traits); ValidationPolicy::is_valid(*itr,*m_traits);
arr_vec[i].first = new Aos_2(m_traits); arr_vec[i].first = new Aos_2(m_traits);
_insert(*itr, *(arr_vec[i].first)); _insert(*itr, *(arr_vec[i].first));
} }
Xor_merge<Aos_2> xor_merge; Xor_merge<Aos_2> xor_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, xor_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, xor_merge);
//the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
} }
@ -747,28 +743,28 @@ public:
template <typename InputIterator1, typename InputIterator2> template <typename InputIterator1, typename InputIterator2>
inline void symmetric_difference(InputIterator1 begin1, InputIterator1 end1, inline void symmetric_difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
unsigned int k = 5) { std::size_t k = 5) {
std::vector<Arr_entry> arr_vec(std::distance(begin1, end1) + std::distance(begin2, end2) + 1); std::vector<Arr_entry> arr_vec(std::distance(begin1, end1) + std::distance(begin2, end2) + 1);
arr_vec[0].first = this->m_arr; arr_vec[0].first = this->m_arr;
unsigned int i = 1; std::size_t i = 1;
for (InputIterator1 itr1 = begin1; itr1!=end1; ++itr1, ++i) { for (InputIterator1 itr1 = begin1; itr1 != end1; ++itr1, ++i) {
ValidationPolicy::is_valid(*itr1, *m_traits); ValidationPolicy::is_valid(*itr1, *m_traits);
arr_vec[i].first = new Aos_2(m_traits); arr_vec[i].first = new Aos_2(m_traits);
_insert(*itr1, *(arr_vec[i].first)); _insert(*itr1, *(arr_vec[i].first));
} }
for (InputIterator2 itr2 = begin2; itr2!=end2; ++itr2, ++i) { for (InputIterator2 itr2 = begin2; itr2 != end2; ++itr2, ++i) {
ValidationPolicy::is_valid(*itr2, *m_traits); ValidationPolicy::is_valid(*itr2, *m_traits);
arr_vec[i].first = new Aos_2(m_traits); arr_vec[i].first = new Aos_2(m_traits);
_insert(*itr2, *(arr_vec[i].first)); _insert(*itr2, *(arr_vec[i].first));
} }
Xor_merge<Aos_2> xor_merge; Xor_merge<Aos_2> xor_merge;
_build_sorted_vertices_vectors (arr_vec); _build_sorted_vertices_vectors(arr_vec);
_divide_and_conquer(0, static_cast<unsigned int>(arr_vec.size()-1), arr_vec, k, xor_merge); _divide_and_conquer(0, arr_vec.size() - 1, arr_vec, k, xor_merge);
//the result arrangement is at index 0 // the result arrangement is at index 0
this->m_arr = arr_vec[0].first; this->m_arr = arr_vec[0].first;
delete arr_vec[0].second; delete arr_vec[0].second;
this->remove_redundant_edges(); this->remove_redundant_edges();
@ -1051,9 +1047,9 @@ protected:
// thus this hack // thus this hack
f = *(face_handles[(*uf_faces.find(face_handles[f->id()]))->id()]); f = *(face_handles[(*uf_faces.find(face_handles[f->id()]))->id()]);
if (h->flag() == ON_INNER_CCB) { if (h->flag() == ON_INNER_CCB) {
bool reuse_inner_ccb = !inner_ccbs_to_remove.empty(); bool reuse_inner_ccb = ! inner_ccbs_to_remove.empty();
typename Dcel::Inner_ccb* inner_ccb = !reuse_inner_ccb? typename Dcel::Inner_ccb* inner_ccb = ! reuse_inner_ccb ?
accessor.new_inner_ccb():inner_ccbs_to_remove.back(); accessor.new_inner_ccb() : inner_ccbs_to_remove.back();
if ( reuse_inner_ccb ) inner_ccbs_to_remove.pop_back(); if ( reuse_inner_ccb ) inner_ccbs_to_remove.pop_back();
Halfedge_handle hstart = h; Halfedge_handle hstart = h;
@ -1115,11 +1111,11 @@ protected:
typename Traits_2::Compare_xy_2 comp_xy; typename Traits_2::Compare_xy_2 comp_xy;
public: public:
Less_vertex_handle (const typename Traits_2::Compare_xy_2& cmp) : Less_vertex_handle(const typename Traits_2::Compare_xy_2& cmp) :
comp_xy(cmp) comp_xy(cmp)
{} {}
bool operator() (Vertex_handle v1, Vertex_handle v2) const bool operator()(Vertex_handle v1, Vertex_handle v2) const
{ return (comp_xy (v1->point(), v2->point()) == SMALLER); } { return (comp_xy (v1->point(), v2->point()) == SMALLER); }
}; };
@ -1136,7 +1132,7 @@ protected:
} }
} }
//fix the directions of the curves (given correct marked face) // fixes the directions of the curves (given correct marked face)
// it should be called mostly after symmetric_difference. // it should be called mostly after symmetric_difference.
void _fix_curves_direction(Aos_2& arr) { void _fix_curves_direction(Aos_2& arr) {
Compare_endpoints_xy_2 cmp_endpoints = Compare_endpoints_xy_2 cmp_endpoints =
@ -1160,21 +1156,17 @@ protected:
} }
void _build_sorted_vertices_vectors(std::vector<Arr_entry>& arr_vec) { void _build_sorted_vertices_vectors(std::vector<Arr_entry>& arr_vec) {
Less_vertex_handle comp (m_traits->compare_xy_2_object()); Less_vertex_handle comp(m_traits->compare_xy_2_object());
Aos_2* p_arr;
Vertex_iterator vit;
const std::size_t n = arr_vec.size(); const std::size_t n = arr_vec.size();
std::size_t i, j; for (std::size_t i = 0; i < n; i++) {
// Allocate a vector of handles to all vertices in the current arrangement.
for (i = 0; i < n; i++) { Aos_2* p_arr = arr_vec[i].first;
// Allocate a vector of handles to all vertices in the current
// arrangement.
p_arr = arr_vec[i].first;
arr_vec[i].second = new std::vector<Vertex_handle>; arr_vec[i].second = new std::vector<Vertex_handle>;
arr_vec[i].second->resize (p_arr->number_of_vertices()); arr_vec[i].second->resize(p_arr->number_of_vertices());
for (j = 0, vit = p_arr->vertices_begin(); vit != p_arr->vertices_end(); j++, ++vit) { std::size_t j = 0;
(*(arr_vec[i].second))[j] = vit; for (auto vit = p_arr->vertices_begin(); vit != p_arr->vertices_end(); ++vit) {
(*(arr_vec[i].second))[j++] = vit;
} }
// Sort the vector. // Sort the vector.
@ -1183,25 +1175,25 @@ protected:
} }
template <typename Merge> template <typename Merge>
void _divide_and_conquer(unsigned int lower, unsigned int upper, void _divide_and_conquer(std::size_t lower, std::size_t upper,
std::vector<Arr_entry>& arr_vec, std::vector<Arr_entry>& arr_vec,
unsigned int k, Merge merge_func) { std::size_t k, Merge merge_func) {
if ((upper - lower) < k) { if ((upper - lower) < k) {
merge_func(lower, upper, 1, arr_vec); merge_func(lower, upper, 1, arr_vec);
return; return;
} }
unsigned int sub_size = ((upper - lower + 1) / k); auto sub_size = ((upper - lower + 1) / k);
unsigned int curr_lower = lower; auto curr_lower = lower;
for (unsigned int i = 0; i < k - 1; ++i, curr_lower += sub_size) { for (std::size_t i = 0; i < k - 1; ++i, curr_lower += sub_size) {
_divide_and_conquer(curr_lower, curr_lower + sub_size-1, arr_vec, k, merge_func); _divide_and_conquer(curr_lower, curr_lower + sub_size-1, arr_vec, k, merge_func);
} }
_divide_and_conquer(curr_lower, upper,arr_vec, k, merge_func); _divide_and_conquer(curr_lower, upper, arr_vec, k, merge_func);
merge_func(lower, curr_lower, sub_size ,arr_vec); merge_func(lower, curr_lower, sub_size, arr_vec);
} }
// mark all faces as non-visited // marks all faces as non-visited
void _reset_faces() const { _reset_faces(m_arr); } void _reset_faces() const { _reset_faces(m_arr); }
void _reset_faces(Aos_2* arr) const { void _reset_faces(Aos_2* arr) const {
@ -1250,7 +1242,7 @@ protected:
GP_Holes_const_iterator> pair = GP_Holes_const_iterator> pair =
m_traits->construct_holes_object()(pgn); m_traits->construct_holes_object()(pgn);
return (unbounded && (pair.first == pair.second)); return (unbounded && (pair.first == pair.second));
//used to return // used to return
// (pgn.is_unbounded() && (pgn.holes_begin() == pgn.holes_end())) // (pgn.is_unbounded() && (pgn.holes_begin() == pgn.holes_end()))
} }
@ -1262,7 +1254,7 @@ protected:
m_arr = res_arr; m_arr = res_arr;
remove_redundant_edges(); remove_redundant_edges();
//fix_curves_direction(); // not needed for intersection // fix_curves_direction(); // not needed for intersection
CGAL_assertion(is_valid()); CGAL_assertion(is_valid());
} }
@ -1315,7 +1307,7 @@ protected:
m_arr = res_arr; m_arr = res_arr;
remove_redundant_edges(); remove_redundant_edges();
//fix_curves_direction(); // not needed for join // fix_curves_direction(); // not needed for join
CGAL_assertion(is_valid()); CGAL_assertion(is_valid());
} }
@ -1323,7 +1315,7 @@ protected:
Gps_join_functor<Aos_2> func; Gps_join_functor<Aos_2> func;
overlay(arr1, arr2, res, func); overlay(arr1, arr2, res, func);
_remove_redundant_edges(&res); _remove_redundant_edges(&res);
//_fix_curves_direction(res); // not needed for join // _fix_curves_direction(res); // not needed for join
CGAL_assertion(_is_valid(res)); CGAL_assertion(_is_valid(res));
} }

View File

@ -8,7 +8,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
#ifndef CGAL_BSO_2_GPS_POLYGON_SIMPILFIER_H #ifndef CGAL_BSO_2_GPS_POLYGON_SIMPILFIER_H
#define CGAL_BSO_2_GPS_POLYGON_SIMPILFIER_H #define CGAL_BSO_2_GPS_POLYGON_SIMPILFIER_H
@ -31,34 +31,33 @@ namespace Ss2 = Surface_sweep_2;
template <typename Arrangement_> template <typename Arrangement_>
class Gps_polygon_simplifier { class Gps_polygon_simplifier {
typedef Arrangement_ Arrangement_2; using Arrangement_2 = Arrangement_;
typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; using Geometry_traits_2 = typename Arrangement_2::Geometry_traits_2;
typedef typename Arrangement_2::Topology_traits Topology_traits; using Topology_traits = typename Arrangement_2::Topology_traits;
typedef Arrangement_2 Arr; using Arr = Arrangement_2;
typedef Geometry_traits_2 Gt2; using Gt2 = Geometry_traits_2;
typedef Topology_traits Tt; using Tt = Topology_traits;
typedef typename Gt2::Curve_const_iterator Curve_const_iterator; using Curve_const_iterator = typename Gt2::Curve_const_iterator;
typedef typename Gt2::Polygon_2 Polygon_2; using Polygon_2 = typename Gt2::Polygon_2;
typedef typename Gt2::Polygon_with_holes_2 Polygon_with_holes_2; using Polygon_with_holes_2 = typename Gt2::Polygon_with_holes_2;
typedef typename Gt2::Construct_curves_2 Construct_curves_2; using Construct_curves_2 = typename Gt2::Construct_curves_2;
typedef Gps_simplifier_traits<Gt2> Mgt2; using Mgt2 = Gps_simplifier_traits<Gt2>;
typedef typename Mgt2::Curve_data Curve_data; using Curve_data = typename Mgt2::Curve_data;
typedef typename Mgt2::X_monotone_curve_2 Meta_X_monotone_curve_2; using Meta_X_monotone_curve_2 = typename Mgt2::X_monotone_curve_2;
typedef typename Arr::Halfedge_handle Halfedge_handle; using Halfedge_handle = typename Arr::Halfedge_handle;
typedef typename Arr::Halfedge_iterator Halfedge_iterator; using Halfedge_iterator = typename Arr::Halfedge_iterator;
typedef typename Arr::Face_handle Face_handle; using Face_handle = typename Arr::Face_handle;
typedef typename Arr::Face_iterator Face_iterator; using Face_iterator = typename Arr::Face_iterator;
typedef typename Arr::Edge_iterator Edge_iterator; using Edge_iterator = typename Arr::Edge_iterator;
typedef typename Arr::Vertex_handle Vertex_handle; using Vertex_handle = typename Arr::Vertex_handle;
typedef typename Arr::Ccb_halfedge_const_circulator using Ccb_halfedge_const_circulator = typename Arr::Ccb_halfedge_const_circulator;
Ccb_halfedge_const_circulator; using Ccb_halfedge_circulator = typename Arr::Ccb_halfedge_circulator;
typedef typename Arr::Ccb_halfedge_circulator Ccb_halfedge_circulator; using Allocator = typename Arr::Allocator;
typedef typename Arr::Allocator Allocator;
// We obtain a proper helper type from the topology traits of the arrangement. // We obtain a proper helper type from the topology traits of the arrangement.
// However, the arrangement is parametrized with the Gt2 geometry traits, // However, the arrangement is parametrized with the Gt2 geometry traits,
@ -67,22 +66,18 @@ class Gps_polygon_simplifier {
// We cannot parameterized the arrangement with the Mgt2 geometry // We cannot parameterized the arrangement with the Mgt2 geometry
// traits to start with, because it extends the curve type with arrangement // traits to start with, because it extends the curve type with arrangement
// dependent types. (It is parameterized with the arrangement type.) // dependent types. (It is parameterized with the arrangement type.)
typedef Indexed_event<Mgt2, Arr, Allocator> Event; using Event = Indexed_event<Mgt2, Arr, Allocator>;
typedef Arr_construction_subcurve<Mgt2, Event, Allocator> using Subcurve = Arr_construction_subcurve<Mgt2, Event, Allocator>;
Subcurve; using Helper_tmp = typename Tt::template Construction_helper<Event, Subcurve>;
typedef typename Tt::template Construction_helper<Event, Subcurve> using Helper = typename Helper_tmp::template rebind<Mgt2, Arr, Event, Subcurve>::other;
Helper_tmp; using Visitor = Gps_agg_op_base_visitor<Helper, Arr>;
typedef typename Helper_tmp::template rebind<Mgt2, Arr, Event, Subcurve>::other using Surface_sweep_2 = Ss2::Surface_sweep_2<Visitor>;
Helper;
typedef Gps_agg_op_base_visitor<Helper, Arr> Visitor;
typedef Ss2::Surface_sweep_2<Visitor> Surface_sweep_2;
typedef Unique_hash_map<Halfedge_handle, unsigned int> using Edges_hash = Unique_hash_map<Halfedge_handle, std::size_t>;
Edges_hash;
typedef Unique_hash_map<Face_handle, unsigned int> Faces_hash; using Faces_hash = Unique_hash_map<Face_handle, std::size_t>;
typedef Gps_bfs_join_visitor<Arr> Bfs_visitor; using Bfs_visitor = Gps_bfs_join_visitor<Arr>;
typedef Gps_bfs_scanner<Arr, Bfs_visitor> Bfs_scanner; using Bfs_scanner = Gps_bfs_scanner<Arr, Bfs_visitor>;
protected: protected:
Arr* m_arr; Arr* m_arr;
@ -104,16 +99,14 @@ public:
{} {}
/*! Destructor. */ /*! Destructor. */
~Gps_polygon_simplifier() ~Gps_polygon_simplifier() {
{
if (m_own_traits && (m_traits != nullptr)) { if (m_own_traits && (m_traits != nullptr)) {
delete m_traits; delete m_traits;
m_traits = nullptr; m_traits = nullptr;
} }
} }
void simplify(const Polygon_2& pgn) void simplify(const Polygon_2& pgn) {
{
Construct_curves_2 ctr_curves = Construct_curves_2 ctr_curves =
reinterpret_cast<const Gt2*>(m_traits)->construct_curves_2_object(); reinterpret_cast<const Gt2*>(m_traits)->construct_curves_2_object();
@ -122,14 +115,13 @@ public:
std::pair<Curve_const_iterator, Curve_const_iterator> itr_pair = std::pair<Curve_const_iterator, Curve_const_iterator> itr_pair =
ctr_curves(pgn); ctr_curves(pgn);
unsigned int index = 0; std::size_t index = 0;
for (Curve_const_iterator itr = itr_pair.first; itr != itr_pair.second; for (Curve_const_iterator itr = itr_pair.first; itr != itr_pair.second;
++itr, ++index) ++itr, ++index) {
{
Curve_data cv_data(1, 0, index); Curve_data cv_data(1, 0, index);
curves_list.push_back(Meta_X_monotone_curve_2(*itr, cv_data)); curves_list.push_back(Meta_X_monotone_curve_2(*itr, cv_data));
} }
m_traits->set_polygon_size(static_cast<unsigned int>(curves_list.size())); m_traits->set_polygon_size(curves_list.size());
m_surface_sweep.sweep(curves_list.begin(), curves_list.end()); m_surface_sweep.sweep(curves_list.begin(), curves_list.end());

View File

@ -8,8 +8,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efifogel@gmail.com> // Efi Fogel <efifogel@gmail.com>
#ifndef CGAL_GPS_SIMPLIFIER_TRAITS_H #ifndef CGAL_GPS_SIMPLIFIER_TRAITS_H
#define CGAL_GPS_SIMPLIFIER_TRAITS_H #define CGAL_GPS_SIMPLIFIER_TRAITS_H
@ -23,97 +23,94 @@ namespace CGAL {
class Gps_simplifier_curve_data { class Gps_simplifier_curve_data {
protected: protected:
unsigned int m_bc; std::size_t m_bc;
unsigned int m_twin_bc; std::size_t m_twin_bc;
unsigned int m_index; std::size_t m_index;
public: public:
Gps_simplifier_curve_data() {} Gps_simplifier_curve_data() {}
Gps_simplifier_curve_data(unsigned int bc, unsigned int twin_bc, Gps_simplifier_curve_data(std::size_t bc, std::size_t twin_bc,
unsigned int index): std::size_t index):
m_bc(bc), m_bc(bc),
m_twin_bc(twin_bc), m_twin_bc(twin_bc),
m_index(index) m_index(index)
{} {}
unsigned int bc() const { return m_bc; } std::size_t bc() const { return m_bc; }
unsigned int twin_bc() const { return m_twin_bc; } std::size_t twin_bc() const { return m_twin_bc; }
unsigned int index() const { return m_index; } std::size_t index() const { return m_index; }
unsigned int& index() { return m_index; } std::size_t& index() { return m_index; }
unsigned int& twin_bc() { return m_twin_bc; } std::size_t& twin_bc() { return m_twin_bc; }
void set_bc(unsigned int bc) { m_bc = bc; } void set_bc(std::size_t bc) { m_bc = bc; }
void set_twin_bc(unsigned int twin_bc) { m_twin_bc = twin_bc; } void set_twin_bc(std::size_t twin_bc) { m_twin_bc = twin_bc; }
void set_index(unsigned int index) { m_index = index; } void set_index(std::size_t index) { m_index = index; }
}; };
struct Gps_simplifier_point_data { struct Gps_simplifier_point_data {
protected: protected:
unsigned int m_index; std::size_t m_index;
public: public:
Gps_simplifier_point_data() {} Gps_simplifier_point_data() {}
Gps_simplifier_point_data(unsigned int index) : m_index(index) {} Gps_simplifier_point_data(std::size_t index) : m_index(index) {}
unsigned int index() const { return m_index; } std::size_t index() const { return m_index; }
void set_index(unsigned int index) { m_index = index; } void set_index(std::size_t index) { m_index = index; }
}; };
template <typename Traits_> template <typename Traits_>
class Gps_simplifier_traits : class Gps_simplifier_traits :
public Gps_traits_decorator<Traits_, public Gps_traits_decorator<Traits_,
Gps_simplifier_curve_data, Gps_simplifier_curve_data,
Gps_simplifier_point_data> Gps_simplifier_point_data> {
{
public: public:
typedef Traits_ Traits; using Traits = Traits_;
typedef Gps_traits_decorator<Traits_, using Base = Gps_traits_decorator<Traits_, Gps_simplifier_curve_data, Gps_simplifier_point_data>;
Gps_simplifier_curve_data, using Self = Gps_simplifier_traits<Traits>;
Gps_simplifier_point_data> Base; using Base_x_monotone_curve_2 = typename Traits::X_monotone_curve_2;
typedef Gps_simplifier_traits<Traits> Self; using Base_point_2 = typename Traits::Point_2;
typedef typename Traits::X_monotone_curve_2 Base_x_monotone_curve_2; using Base_Construct_min_vertex_2 = typename Traits::Construct_min_vertex_2;
typedef typename Traits::Point_2 Base_point_2; using Base_Construct_max_vertex_2 = typename Traits::Construct_max_vertex_2;
typedef typename Traits::Construct_min_vertex_2 Base_Construct_min_vertex_2; using Base_Compare_endpoints_xy_2 = typename Traits::Compare_endpoints_xy_2;
typedef typename Traits::Construct_max_vertex_2 Base_Construct_max_vertex_2; using Base_Compare_xy_2 = typename Traits::Compare_xy_2;
typedef typename Traits::Compare_endpoints_xy_2 Base_Compare_endpoints_xy_2; using Base_Compare_y_at_x_right_2 = typename Traits::Compare_y_at_x_right_2;
typedef typename Traits::Compare_xy_2 Base_Compare_xy_2; using Base_Compare_y_at_x_2 = typename Traits::Compare_y_at_x_2;
typedef typename Traits::Compare_y_at_x_right_2 Base_Compare_y_at_x_right_2; using Base_Intersect_2 = typename Traits::Intersect_2;
typedef typename Traits::Compare_y_at_x_2 Base_Compare_y_at_x_2; using Base_Split_2 = typename Traits::Split_2;
typedef typename Traits::Intersect_2 Base_Intersect_2;
typedef typename Traits::Split_2 Base_Split_2;
protected: protected:
mutable unsigned int m_pgn_size; mutable std::size_t m_pgn_size;
public: public:
typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; using X_monotone_curve_2 = typename Base::X_monotone_curve_2;
typedef typename Base::Point_2 Point_2; using Point_2 = typename Base::Point_2;
typedef typename Base::Multiplicity Multiplicity; using Multiplicity = typename Base::Multiplicity;
typedef typename Base::Curve_data Curve_data; using Curve_data = typename Base::Curve_data;
typedef typename Base::Point_data Point_data; using Point_data = typename Base::Point_data;
Gps_simplifier_traits() {} Gps_simplifier_traits() {}
Gps_simplifier_traits(const Traits& tr) : Base(tr) {} Gps_simplifier_traits(const Traits& tr) : Base(tr) {}
unsigned int polygon_size() const { return m_pgn_size; } std::size_t polygon_size() const { return m_pgn_size; }
void set_polygon_size(unsigned int pgn_size) const { m_pgn_size = pgn_size; } void set_polygon_size(std::size_t pgn_size) const { m_pgn_size = pgn_size; }
bool is_valid_index(unsigned int index) const bool is_valid_index(std::size_t index) const
{ return (index < m_pgn_size); } { return (index < m_pgn_size); }
unsigned int invalid_index() const { return (m_pgn_size); } std::size_t invalid_index() const { return (m_pgn_size); }
class Intersect_2 { class Intersect_2 {
private: private:
@ -129,12 +126,9 @@ 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_base_point = const std::pair<Base_point_2, Multiplicity>;
typedef const std::pair<Base_point_2, Multiplicity> using Intersection_base_result = std::variant<Intersection_base_point, Base_x_monotone_curve_2>;
Intersection_base_point;
typedef std::variant<Intersection_base_point, Base_x_monotone_curve_2>
Intersection_base_result;
const auto* base_traits = m_traits.m_base_traits; const auto* base_traits = m_traits.m_base_traits;
auto base_cmp_xy = base_traits->compare_xy_2_object(); auto base_cmp_xy = base_traits->compare_xy_2_object();
@ -146,7 +140,7 @@ public:
//if (m_traits.is_valid_index(cv1.data().index()) && //if (m_traits.is_valid_index(cv1.data().index()) &&
// m_traits.is_valid_index(cv2.data().index())) // m_traits.is_valid_index(cv2.data().index()))
//{ //{
// unsigned int index_diff = // std::size_t index_diff =
// (cv1.data().index() > cv2.data().index()) ? // (cv1.data().index() > cv2.data().index()) ?
// (cv1.data().index() - cv2.data().index()): // (cv1.data().index() - cv2.data().index()):
// (cv2.data().index() - cv1.data().index()); // (cv2.data().index() - cv1.data().index());
@ -180,8 +174,8 @@ public:
std::get_if<Base_x_monotone_curve_2>(&xection); std::get_if<Base_x_monotone_curve_2>(&xection);
CGAL_assertion(overlap_cv != nullptr); CGAL_assertion(overlap_cv != nullptr);
unsigned int ov_bc; std::size_t ov_bc;
unsigned int ov_twin_bc; std::size_t ov_twin_bc;
if (base_cmp_endpoints(cv1) == base_cmp_endpoints(cv2)) { if (base_cmp_endpoints(cv1) == base_cmp_endpoints(cv2)) {
// cv1 and cv2 have the same directions // cv1 and cv2 have the same directions
ov_bc = cv1.data().bc() + cv2.data().bc(); ov_bc = cv1.data().bc() + cv2.data().bc();
@ -207,7 +201,7 @@ public:
}; };
/*! Obtain an Intersect_2 functor object. */ /*! Obtain an Intersect_2 functor object. */
Intersect_2 intersect_2_object () const { return Intersect_2(*this); } Intersect_2 intersect_2_object() const { return Intersect_2(*this); }
class Split_2 { class Split_2 {
private: private:
@ -250,8 +244,7 @@ public:
* \param cv The curve. * \param cv The curve.
* \return The left endpoint. * \return The left endpoint.
*/ */
Point_2 operator()(const X_monotone_curve_2 & cv) const Point_2 operator()(const X_monotone_curve_2 & cv) const {
{
const auto* base_traits = m_traits.m_base_traits; const auto* base_traits = m_traits.m_base_traits;
auto base_ctr_min_vertex = base_traits->construct_min_vertex_2_object(); auto base_ctr_min_vertex = base_traits->construct_min_vertex_2_object();
@ -290,8 +283,7 @@ public:
* \param cv The curve. * \param cv The curve.
* \return The left endpoint. * \return The left endpoint.
*/ */
Point_2 operator() (const X_monotone_curve_2 & cv) const Point_2 operator() (const X_monotone_curve_2 & cv) const {
{
const auto* base_traits = m_traits.m_base_traits; const auto* base_traits = m_traits.m_base_traits;
auto base_ctr_max_vertex = base_traits->construct_max_vertex_2_object(); auto base_ctr_max_vertex = base_traits->construct_max_vertex_2_object();
if (! m_traits.is_valid_index(cv.data().index())) if (! m_traits.is_valid_index(cv.data().index()))
@ -329,8 +321,7 @@ public:
* \param cv The curve. * \param cv The curve.
* \return The left endpoint. * \return The left endpoint.
*/ */
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 auto* base_traits = m_traits.m_base_traits; const auto* base_traits = m_traits.m_base_traits;
auto base_cmp_xy = base_traits->compare_xy_2_object(); auto base_cmp_xy = base_traits->compare_xy_2_object();

View File

@ -32,17 +32,16 @@ class Indexed_event :
Arrangement_, Arrangement_,
Allocator_>, Allocator_>,
Allocator_>, Allocator_>,
Arrangement_> Arrangement_> {
{
private: private:
unsigned int m_index; std::size_t m_index;
public: public:
Indexed_event() : m_index (0) {} Indexed_event() : m_index (0) {}
unsigned int index() const { return (m_index); } std::size_t index() const { return (m_index); }
void set_index(unsigned int index) { m_index = index; } void set_index(std::size_t index) { m_index = index; }
}; };
} // namespace CGAL } // namespace CGAL

View File

@ -201,13 +201,13 @@ inline bool do_intersect(const General_polygon_with_holes_2<Polygon_>& pgn1,
// With Traits // With Traits
template <typename InputIterator, typename Traits> template <typename InputIterator, typename Traits>
inline bool do_intersect(InputIterator begin, InputIterator end, Traits& traits, inline bool do_intersect(InputIterator begin, InputIterator end, Traits& traits,
unsigned int k = 5, std::size_t k = 5,
std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0) std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0)
{ return r_do_intersect(begin, end, traits, k); } { return r_do_intersect(begin, end, traits, k); }
// Without Traits // Without Traits
template <typename InputIterator> template <typename InputIterator>
inline bool do_intersect(InputIterator begin, InputIterator end, unsigned int k = 5, inline bool do_intersect(InputIterator begin, InputIterator end, std::size_t k = 5,
std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0, std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0,
Enable_if_Polygon_2_iterator<InputIterator>* = 0) { Enable_if_Polygon_2_iterator<InputIterator>* = 0) {
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
@ -217,7 +217,7 @@ inline bool do_intersect(InputIterator begin, InputIterator end, unsigned int k
// General polygons or polygons with holes // General polygons or polygons with holes
template <typename InputIterator> template <typename InputIterator>
inline bool do_intersect(InputIterator begin, InputIterator end, inline bool do_intersect(InputIterator begin, InputIterator end,
unsigned int k = 5, std::size_t k = 5,
std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0, std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0,
Disable_if_Polygon_2_iterator<InputIterator>* = 0) { Disable_if_Polygon_2_iterator<InputIterator>* = 0) {
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
@ -228,14 +228,14 @@ inline bool do_intersect(InputIterator begin, InputIterator end,
template <typename InputIterator1, typename InputIterator2, typename Traits> template <typename InputIterator1, typename InputIterator2, typename Traits>
inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1, inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
Traits& traits, unsigned int k = 5) Traits& traits, std::size_t k = 5)
{ return r_do_intersect(begin1, end1, begin2, end2, traits, k); } { return r_do_intersect(begin1, end1, begin2, end2, traits, k); }
// Without Traits // Without Traits
template <typename InputIterator1, typename InputIterator2> template <typename InputIterator1, typename InputIterator2>
inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1, inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
unsigned int k = 5, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator1>* = 0) Enable_if_Polygon_2_iterator<InputIterator1>* = 0)
{ return r_do_intersect(begin1, end1, begin2, end2, k); } { return r_do_intersect(begin1, end1, begin2, end2, k); }
@ -243,7 +243,7 @@ inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1,
template <typename InputIterator1, typename InputIterator2> template <typename InputIterator1, typename InputIterator2>
inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1, inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
unsigned int k = 5, std::size_t k = 5,
Disable_if_Polygon_2_iterator<InputIterator1>* = 0) { Disable_if_Polygon_2_iterator<InputIterator1>* = 0) {
typename Iterator_to_gps_traits<InputIterator1>::Traits traits; typename Iterator_to_gps_traits<InputIterator1>::Traits traits;
return r_do_intersect(begin1, end1, begin2, end2, traits, k); return r_do_intersect(begin1, end1, begin2, end2, traits, k);

View File

@ -8,10 +8,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il> // Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il> // Efi Fogel <efif@post.tau.ac.il>
// Simon Giraudot <simon.giraudot@geometryfactory.com> // Simon Giraudot <simon.giraudot@geometryfactory.com>
#ifndef CGAL_BOOLEAN_SET_OPERATIONS_2_INTERSECTION_H #ifndef CGAL_BOOLEAN_SET_OPERATIONS_2_INTERSECTION_H
#define CGAL_BOOLEAN_SET_OPERATIONS_2_INTERSECTION_H #define CGAL_BOOLEAN_SET_OPERATIONS_2_INTERSECTION_H
@ -33,8 +33,7 @@
#include <CGAL/Boolean_set_operations_2/Polygon_conversions.h> #include <CGAL/Boolean_set_operations_2/Polygon_conversions.h>
#include <CGAL/type_traits/is_iterator.h> #include <CGAL/type_traits/is_iterator.h>
namespace CGAL namespace CGAL {
{
/// \name intersection() functions. /// \name intersection() functions.
//@{ //@{
@ -59,10 +58,9 @@ inline OutputIterator intersection(const Polygon_2<Kernel, Container>& pgn1,
template <typename Kernel, typename Container, typename OutputIterator> template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator intersection(const Polygon_2<Kernel, Container>& pgn1, inline OutputIterator intersection(const Polygon_2<Kernel, Container>& pgn1,
const Polygon_2<Kernel, Container>& pgn2, const Polygon_2<Kernel, Container>& pgn2,
OutputIterator out, Tag_false) OutputIterator out, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_2<Kernel, Container> Polygon; using Polygon = Polygon_2<Kernel, Container>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -90,10 +88,9 @@ template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator inline OutputIterator
intersection(const Polygon_2<Kernel, Container>& pgn1, intersection(const Polygon_2<Kernel, Container>& pgn1,
const Polygon_with_holes_2<Kernel, Container>& pgn2, const Polygon_with_holes_2<Kernel, Container>& pgn2,
OutputIterator out, Tag_false) OutputIterator out, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_2<Kernel, Container> Polygon; using Polygon = Polygon_2<Kernel, Container>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -121,10 +118,9 @@ template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator inline OutputIterator
intersection(const Polygon_with_holes_2<Kernel, Container>& pgn1, intersection(const Polygon_with_holes_2<Kernel, Container>& pgn1,
const Polygon_2<Kernel, Container>& pgn2, const Polygon_2<Kernel, Container>& pgn2,
OutputIterator out, Tag_false) OutputIterator out, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_with_holes_2<Kernel, Container> Polygon_with_holes; using Polygon_with_holes = Polygon_with_holes_2<Kernel, Container>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -152,10 +148,9 @@ template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator inline OutputIterator
intersection(const Polygon_with_holes_2<Kernel, Container>& pgn1, intersection(const Polygon_with_holes_2<Kernel, Container>& pgn1,
const Polygon_with_holes_2<Kernel, Container>& pgn2, const Polygon_with_holes_2<Kernel, Container>& pgn2,
OutputIterator out, Tag_false) OutputIterator out, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_with_holes_2<Kernel, Container> Polygon_with_holes; using Polygon_with_holes = Polygon_with_holes_2<Kernel, Container>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -172,10 +167,9 @@ inline OutputIterator intersection(const General_polygon_2<ArrTraits>& pgn1,
template <typename ArrTraits, typename OutputIterator> template <typename ArrTraits, typename OutputIterator>
inline OutputIterator intersection(const General_polygon_2<ArrTraits>& pgn1, inline OutputIterator intersection(const General_polygon_2<ArrTraits>& pgn1,
const General_polygon_2<ArrTraits>& pgn2, const General_polygon_2<ArrTraits>& pgn2,
OutputIterator out) OutputIterator out) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -194,10 +188,9 @@ template <typename ArrTraits, typename OutputIterator>
inline OutputIterator intersection(const General_polygon_2<ArrTraits>& pgn1, inline OutputIterator intersection(const General_polygon_2<ArrTraits>& pgn1,
const General_polygon_with_holes_2 const General_polygon_with_holes_2
<General_polygon_2<ArrTraits> >& pgn2, <General_polygon_2<ArrTraits> >& pgn2,
OutputIterator out) OutputIterator out) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -216,11 +209,10 @@ template <typename ArrTraits, typename OutputIterator>
inline OutputIterator intersection(const General_polygon_with_holes_2 inline OutputIterator intersection(const General_polygon_with_holes_2
<General_polygon_2<ArrTraits> >& pgn1, <General_polygon_2<ArrTraits> >& pgn1,
const General_polygon_2<ArrTraits>& pgn2, const General_polygon_2<ArrTraits>& pgn2,
OutputIterator out) OutputIterator out) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typedef General_polygon_with_holes_2<Polygon> Polygon_with_holes; using Polygon_with_holes = General_polygon_with_holes_2<Polygon>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -239,10 +231,9 @@ template <typename Polygon_, typename OutputIterator>
inline OutputIterator inline OutputIterator
intersection(const General_polygon_with_holes_2<Polygon_>& pgn1, intersection(const General_polygon_with_holes_2<Polygon_>& pgn1,
const General_polygon_with_holes_2<Polygon_>& pgn2, const General_polygon_with_holes_2<Polygon_>& pgn2,
OutputIterator out) OutputIterator out) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_with_holes_2<Polygon_> Polygon_with_holes; using Polygon_with_holes = General_polygon_with_holes_2<Polygon_>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_intersection(pgn1, pgn2, out, traits); return s_intersection(pgn1, pgn2, out, traits);
} }
@ -256,7 +247,7 @@ intersection(const General_polygon_with_holes_2<Polygon_>& pgn1,
template <typename InputIterator, typename OutputIterator, typename Traits> template <typename InputIterator, typename OutputIterator, typename Traits>
inline OutputIterator intersection(InputIterator begin, InputIterator end, inline OutputIterator intersection(InputIterator begin, InputIterator end,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k=5) std::size_t k = 5)
{ return r_intersection(begin, end, oi, traits, k); } { return r_intersection(begin, end, oi, traits, k); }
// Without Traits // Without Traits
@ -265,7 +256,7 @@ template <typename InputIterator, typename OutputIterator>
inline OutputIterator inline OutputIterator
intersection(InputIterator begin, InputIterator end, intersection(InputIterator begin, InputIterator end,
OutputIterator oi, Tag_true = Tag_true(), OutputIterator oi, Tag_true = Tag_true(),
unsigned int k=5, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator>* = 0) Enable_if_Polygon_2_iterator<InputIterator>* = 0)
{ return r_intersection(begin, end, oi, k); } { return r_intersection(begin, end, oi, k); }
@ -273,9 +264,8 @@ intersection(InputIterator begin, InputIterator end,
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator inline OutputIterator
intersection(InputIterator begin, InputIterator end, intersection(InputIterator begin, InputIterator end,
OutputIterator oi, Tag_false, unsigned int k=5, OutputIterator oi, Tag_false, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator>* = 0) Enable_if_Polygon_2_iterator<InputIterator>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
return r_intersection(begin, end, oi, traits, k); return r_intersection(begin, end, oi, traits, k);
} }
@ -284,11 +274,10 @@ intersection(InputIterator begin, InputIterator end,
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator inline OutputIterator
intersection(InputIterator begin, InputIterator end, intersection(InputIterator begin, InputIterator end,
OutputIterator oi, unsigned int k=5, OutputIterator oi, std::size_t k = 5,
// workaround to avoid ambiguous calls with kernel functions // workaround to avoid ambiguous calls with kernel functions
std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0, std::enable_if_t<CGAL::is_iterator<InputIterator>::value>* = 0,
Disable_if_Polygon_2_iterator<InputIterator>* = 0) Disable_if_Polygon_2_iterator<InputIterator>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
return r_intersection(begin, end, oi, traits, k); return r_intersection(begin, end, oi, traits, k);
} }
@ -300,7 +289,7 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator intersection(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k=5) std::size_t k = 5)
{ return r_intersection(begin1, end1, begin2, end2, oi, traits, k); } { return r_intersection(begin1, end1, begin2, end2, oi, traits, k); }
// Without Traits // Without Traits
@ -310,7 +299,7 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator inline OutputIterator
intersection(InputIterator1 begin1, InputIterator1 end1, intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Tag_true = Tag_true(), unsigned int k=5, OutputIterator oi, Tag_true = Tag_true(), std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator1>* = 0) Enable_if_Polygon_2_iterator<InputIterator1>* = 0)
{ return r_intersection(begin1, end1, begin2, end2, oi, k); } { return r_intersection(begin1, end1, begin2, end2, oi, k); }
@ -320,9 +309,8 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator inline OutputIterator
intersection(InputIterator1 begin1, InputIterator1 end1, intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Tag_false, unsigned int k=5, OutputIterator oi, Tag_false, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator1>* = 0) Enable_if_Polygon_2_iterator<InputIterator1>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator1>::Traits traits; typename Iterator_to_gps_traits<InputIterator1>::Traits traits;
return r_intersection(begin1, end1, begin2, end2, oi, traits, k); return r_intersection(begin1, end1, begin2, end2, oi, traits, k);
} }
@ -333,9 +321,8 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator inline OutputIterator
intersection(InputIterator1 begin1, InputIterator1 end1, intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, unsigned int k=5, OutputIterator oi, std::size_t k = 5,
Disable_if_Polygon_2_iterator<InputIterator1>* = 0) Disable_if_Polygon_2_iterator<InputIterator1>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator1>::Traits traits; typename Iterator_to_gps_traits<InputIterator1>::Traits traits;
return r_intersection(begin1, end1, begin2, end2, oi, traits, k); return r_intersection(begin1, end1, begin2, end2, oi, traits, k);
} }

View File

@ -8,10 +8,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il> // Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il> // Efi Fogel <efif@post.tau.ac.il>
// Simon Giraudot <simon.giraudot@geometryfactory.com> // Simon Giraudot <simon.giraudot@geometryfactory.com>
#ifndef CGAL_BOOLEAN_SET_OPERATIONS_2_JOIN_H #ifndef CGAL_BOOLEAN_SET_OPERATIONS_2_JOIN_H
#define CGAL_BOOLEAN_SET_OPERATIONS_2_JOIN_H #define CGAL_BOOLEAN_SET_OPERATIONS_2_JOIN_H
@ -33,8 +33,7 @@
#include <CGAL/Boolean_set_operations_2/Polygon_conversions.h> #include <CGAL/Boolean_set_operations_2/Polygon_conversions.h>
#include <CGAL/type_traits/is_iterator.h> #include <CGAL/type_traits/is_iterator.h>
namespace CGAL namespace CGAL {
{
/// \name join() functions. /// \name join() functions.
//@{ //@{
@ -60,10 +59,9 @@ template <typename Kernel, typename Container>
inline bool join(const Polygon_2<Kernel, Container>& pgn1, inline bool join(const Polygon_2<Kernel, Container>& pgn1,
const Polygon_2<Kernel, Container>& pgn2, const Polygon_2<Kernel, Container>& pgn2,
Polygon_with_holes_2<Kernel, Container>& res, Polygon_with_holes_2<Kernel, Container>& res,
Tag_false) Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_2<Kernel, Container> Polygon; using Polygon = Polygon_2<Kernel, Container>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -89,10 +87,9 @@ template <typename Kernel, typename Container>
inline bool join(const Polygon_2<Kernel, Container>& pgn1, inline bool join(const Polygon_2<Kernel, Container>& pgn1,
const Polygon_with_holes_2<Kernel, Container>& pgn2, const Polygon_with_holes_2<Kernel, Container>& pgn2,
Polygon_with_holes_2<Kernel, Container>& res, Polygon_with_holes_2<Kernel, Container>& res,
Tag_false) Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_2<Kernel, Container> Polygon; using Polygon = Polygon_2<Kernel, Container>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -118,10 +115,9 @@ template <typename Kernel, typename Container>
inline bool join(const Polygon_with_holes_2<Kernel, Container>& pgn1, inline bool join(const Polygon_with_holes_2<Kernel, Container>& pgn1,
const Polygon_2<Kernel, Container>& pgn2, const Polygon_2<Kernel, Container>& pgn2,
Polygon_with_holes_2<Kernel, Container>& res, Polygon_with_holes_2<Kernel, Container>& res,
Tag_false) Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_with_holes_2<Kernel, Container> Polygon_with_holes; using Polygon_with_holes = Polygon_with_holes_2<Kernel, Container>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -147,10 +143,9 @@ template <typename Kernel, typename Container>
inline bool join(const Polygon_with_holes_2<Kernel, Container>& pgn1, inline bool join(const Polygon_with_holes_2<Kernel, Container>& pgn1,
const Polygon_with_holes_2<Kernel, Container>& pgn2, const Polygon_with_holes_2<Kernel, Container>& pgn2,
Polygon_with_holes_2<Kernel, Container>& res, Polygon_with_holes_2<Kernel, Container>& res,
Tag_false) Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_with_holes_2<Kernel, Container> Polygon_with_holes; using Polygon_with_holes = Polygon_with_holes_2<Kernel, Container>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -170,10 +165,9 @@ template <typename ArrTraits>
inline bool inline bool
join(const General_polygon_2<ArrTraits>& pgn1, join(const General_polygon_2<ArrTraits>& pgn1,
const General_polygon_2<ArrTraits>& pgn2, const General_polygon_2<ArrTraits>& pgn2,
General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& res) General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& res) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -193,10 +187,9 @@ template <typename ArrTraits>
inline bool inline bool
join(const General_polygon_2<ArrTraits>& pgn1, join(const General_polygon_2<ArrTraits>& pgn1,
const General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& pgn2, const General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& pgn2,
General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& res) General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& res) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -216,11 +209,10 @@ template <typename ArrTraits>
inline bool inline bool
join(const General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& pgn1, join(const General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& pgn1,
const General_polygon_2<ArrTraits>& pgn2, const General_polygon_2<ArrTraits>& pgn2,
General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& res) General_polygon_with_holes_2<General_polygon_2<ArrTraits> >& res) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typedef General_polygon_with_holes_2<Polygon> Polygon_with_holes; using Polygon_with_holes = General_polygon_with_holes_2<Polygon>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -237,10 +229,9 @@ inline bool join(const General_polygon_with_holes_2<Polygon_>& pgn1,
template <typename Polygon_> template <typename Polygon_>
inline bool join(const General_polygon_with_holes_2<Polygon_>& pgn1, inline bool join(const General_polygon_with_holes_2<Polygon_>& pgn1,
const General_polygon_with_holes_2<Polygon_>& pgn2, const General_polygon_with_holes_2<Polygon_>& pgn2,
General_polygon_with_holes_2<Polygon_>& res) General_polygon_with_holes_2<Polygon_>& res) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_with_holes_2<Polygon_> Polygon_with_holes; using Polygon_with_holes = General_polygon_with_holes_2<Polygon_>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_join(pgn1, pgn2, res, traits); return s_join(pgn1, pgn2, res, traits);
} }
@ -253,7 +244,7 @@ inline bool join(const General_polygon_with_holes_2<Polygon_>& pgn1,
// With Traits // With Traits
template <typename InputIterator, typename OutputIterator, typename Traits> template <typename InputIterator, typename OutputIterator, typename Traits>
inline OutputIterator join(InputIterator begin, InputIterator end, inline OutputIterator join(InputIterator begin, InputIterator end,
OutputIterator oi, Traits& traits, unsigned int k=5) OutputIterator oi, Traits& traits, std::size_t k = 5)
{ return r_join(begin, end, oi, traits, k); } { return r_join(begin, end, oi, traits, k); }
// Without Traits // Without Traits
@ -261,16 +252,15 @@ inline OutputIterator join(InputIterator begin, InputIterator end,
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator join(InputIterator begin, InputIterator end, inline OutputIterator join(InputIterator begin, InputIterator end,
OutputIterator oi, Tag_true = Tag_true(), OutputIterator oi, Tag_true = Tag_true(),
unsigned int k=5, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator>* = 0) Enable_if_Polygon_2_iterator<InputIterator>* = 0)
{ return r_join(begin, end, oi, k); } { return r_join(begin, end, oi, k); }
// Tag_false => do not convert to polylines // Tag_false => do not convert to polylines
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator join(InputIterator begin, InputIterator end, inline OutputIterator join(InputIterator begin, InputIterator end,
OutputIterator oi, Tag_false, unsigned int k=5, OutputIterator oi, Tag_false, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator>* = 0) Enable_if_Polygon_2_iterator<InputIterator>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
return r_join(begin, end, oi, traits, k); return r_join(begin, end, oi, traits, k);
} }
@ -278,9 +268,8 @@ inline OutputIterator join(InputIterator begin, InputIterator end,
// General polygons or polygons with holes // General polygons or polygons with holes
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator join(InputIterator begin, InputIterator end, inline OutputIterator join(InputIterator begin, InputIterator end,
OutputIterator oi, unsigned int k=5, OutputIterator oi, std::size_t k = 5,
Disable_if_Polygon_2_iterator<InputIterator>* = 0) Disable_if_Polygon_2_iterator<InputIterator>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
return r_join(begin, end, oi, traits, k); return r_join(begin, end, oi, traits, k);
} }
@ -291,7 +280,7 @@ template <typename InputIterator1, typename InputIterator2,
typename OutputIterator, typename Traits> typename OutputIterator, typename Traits>
inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Traits& traits, unsigned int k=5) OutputIterator oi, Traits& traits, std::size_t k = 5)
{ return r_join(begin1, end1, begin2, end2, oi, traits, k); } { return r_join(begin1, end1, begin2, end2, oi, traits, k); }
// Without Traits // Without Traits
@ -301,7 +290,7 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Tag_true = Tag_true(), OutputIterator oi, Tag_true = Tag_true(),
unsigned int k=5, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator1>* = 0) Enable_if_Polygon_2_iterator<InputIterator1>* = 0)
{ return r_join(begin1, end1, begin2, end2, oi, k); } { return r_join(begin1, end1, begin2, end2, oi, k); }
@ -310,9 +299,8 @@ template <typename InputIterator1, typename InputIterator2,
typename OutputIterator> typename OutputIterator>
inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Tag_false, unsigned int k=5, OutputIterator oi, Tag_false, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator1>* = 0) Enable_if_Polygon_2_iterator<InputIterator1>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator1>::Traits traits; typename Iterator_to_gps_traits<InputIterator1>::Traits traits;
return r_join(begin1, end1, begin2, end2, oi, traits, k); return r_join(begin1, end1, begin2, end2, oi, traits, k);
} }
@ -322,9 +310,8 @@ template <typename InputIterator1, typename InputIterator2,
typename OutputIterator> typename OutputIterator>
inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1, inline OutputIterator join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, unsigned int k=5, OutputIterator oi, std::size_t k = 5,
Disable_if_Polygon_2_iterator<InputIterator1>* = 0) Disable_if_Polygon_2_iterator<InputIterator1>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator1>::Traits traits; typename Iterator_to_gps_traits<InputIterator1>::Traits traits;
return r_join(begin1, end1, begin2, end2, oi, traits, k); return r_join(begin1, end1, begin2, end2, oi, traits, k);
} }

View File

@ -8,10 +8,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Ron Wein <wein@post.tau.ac.il> // Ron Wein <wein@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il> // Efi Fogel <efif@post.tau.ac.il>
// Simon Giraudot <simon.giraudot@geometryfactory.com> // Simon Giraudot <simon.giraudot@geometryfactory.com>
#ifndef CGAL_BOOLEAN_SET_OPERATIONS_SYMMETRIC_DIFFERENCE_H #ifndef CGAL_BOOLEAN_SET_OPERATIONS_SYMMETRIC_DIFFERENCE_H
#define CGAL_BOOLEAN_SET_OPERATIONS_SYMMETRIC_DIFFERENCE_H #define CGAL_BOOLEAN_SET_OPERATIONS_SYMMETRIC_DIFFERENCE_H
@ -33,8 +33,7 @@
#include <CGAL/Boolean_set_operations_2/Polygon_conversions.h> #include <CGAL/Boolean_set_operations_2/Polygon_conversions.h>
#include <CGAL/type_traits/is_iterator.h> #include <CGAL/type_traits/is_iterator.h>
namespace CGAL namespace CGAL {
{
/// \name symmetric_difference() functions. /// \name symmetric_difference() functions.
//@{ //@{
@ -62,10 +61,9 @@ template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(const Polygon_2<Kernel, Container>& pgn1, symmetric_difference(const Polygon_2<Kernel, Container>& pgn1,
const Polygon_2<Kernel, Container>& pgn2, const Polygon_2<Kernel, Container>& pgn2,
OutputIterator oi, Tag_false) OutputIterator oi, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_2<Kernel, Container> Polygon; using Polygon = Polygon_2<Kernel, Container>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -93,10 +91,9 @@ template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(const Polygon_2<Kernel, Container>& pgn1, symmetric_difference(const Polygon_2<Kernel, Container>& pgn1,
const Polygon_with_holes_2<Kernel, Container>& pgn2, const Polygon_with_holes_2<Kernel, Container>& pgn2,
OutputIterator oi, Tag_false) OutputIterator oi, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_2<Kernel, Container> Polygon; using Polygon = Polygon_2<Kernel, Container>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -124,10 +121,9 @@ template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(const Polygon_with_holes_2<Kernel, Container>& pgn1, symmetric_difference(const Polygon_with_holes_2<Kernel, Container>& pgn1,
const Polygon_2<Kernel, Container>& pgn2, const Polygon_2<Kernel, Container>& pgn2,
OutputIterator oi, Tag_false) OutputIterator oi, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_with_holes_2<Kernel, Container> Polygon_with_holes; using Polygon_with_holes = Polygon_with_holes_2<Kernel, Container>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -155,10 +151,9 @@ template <typename Kernel, typename Container, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(const Polygon_with_holes_2<Kernel, Container>& pgn1, symmetric_difference(const Polygon_with_holes_2<Kernel, Container>& pgn1,
const Polygon_with_holes_2<Kernel, Container>& pgn2, const Polygon_with_holes_2<Kernel, Container>& pgn2,
OutputIterator oi, Tag_false) OutputIterator oi, Tag_false) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef Polygon_with_holes_2<Kernel, Container> Polygon_with_holes; using Polygon_with_holes = Polygon_with_holes_2<Kernel, Container>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -176,10 +171,9 @@ template <typename ArrTraits, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(const General_polygon_2<ArrTraits>& pgn1, symmetric_difference(const General_polygon_2<ArrTraits>& pgn1,
const General_polygon_2<ArrTraits>& pgn2, const General_polygon_2<ArrTraits>& pgn2,
OutputIterator oi) OutputIterator oi) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -200,10 +194,9 @@ inline OutputIterator
symmetric_difference(const General_polygon_2<ArrTraits>& pgn1, symmetric_difference(const General_polygon_2<ArrTraits>& pgn1,
const General_polygon_with_holes_2 const General_polygon_with_holes_2
<General_polygon_2<ArrTraits> >& pgn2, <General_polygon_2<ArrTraits> >& pgn2,
OutputIterator oi) OutputIterator oi) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typename Gps_default_traits<Polygon>::Traits traits; typename Gps_default_traits<Polygon>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -224,11 +217,10 @@ inline OutputIterator
symmetric_difference(const General_polygon_with_holes_2 symmetric_difference(const General_polygon_with_holes_2
<General_polygon_2<ArrTraits> >& pgn1, <General_polygon_2<ArrTraits> >& pgn1,
const General_polygon_2<ArrTraits>& pgn2, const General_polygon_2<ArrTraits>& pgn2,
OutputIterator oi) OutputIterator oi) {
{
// Use the first polygon to determine the (default) traits // Use the first polygon to determine the (default) traits
typedef General_polygon_2<ArrTraits> Polygon; using Polygon = General_polygon_2<ArrTraits>;
typedef General_polygon_with_holes_2<Polygon> Polygon_with_holes; using Polygon_with_holes = General_polygon_with_holes_2<Polygon>;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -247,9 +239,8 @@ template <typename Polygon_, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(const General_polygon_with_holes_2<Polygon_>& pgn1, symmetric_difference(const General_polygon_with_holes_2<Polygon_>& pgn1,
const General_polygon_with_holes_2<Polygon_>& pgn2, const General_polygon_with_holes_2<Polygon_>& pgn2,
OutputIterator oi) OutputIterator oi) {
{ using Polygon_with_holes = General_polygon_with_holes_2<Polygon_>;
typedef General_polygon_with_holes_2<Polygon_> Polygon_with_holes;
typename Gps_default_traits<Polygon_with_holes>::Traits traits; typename Gps_default_traits<Polygon_with_holes>::Traits traits;
return s_symmetric_difference(pgn1, pgn2, oi, traits); return s_symmetric_difference(pgn1, pgn2, oi, traits);
} }
@ -264,7 +255,7 @@ template <typename InputIterator, typename OutputIterator, typename Traits>
inline inline
OutputIterator symmetric_difference(InputIterator begin, InputIterator end, OutputIterator symmetric_difference(InputIterator begin, InputIterator end,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k=5) std::size_t k = 5)
{ return r_symmetric_difference(begin, end, oi, traits, k); } { return r_symmetric_difference(begin, end, oi, traits, k); }
// Without Traits // Without Traits
@ -272,7 +263,7 @@ OutputIterator symmetric_difference(InputIterator begin, InputIterator end,
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(InputIterator begin, InputIterator end, symmetric_difference(InputIterator begin, InputIterator end,
OutputIterator oi, Tag_true = Tag_true(), unsigned int k=5, OutputIterator oi, Tag_true = Tag_true(), std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator>* = 0) Enable_if_Polygon_2_iterator<InputIterator>* = 0)
{ return r_symmetric_difference(begin, end, oi, k); } { return r_symmetric_difference(begin, end, oi, k); }
@ -280,9 +271,8 @@ symmetric_difference(InputIterator begin, InputIterator end,
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(InputIterator begin, InputIterator end, symmetric_difference(InputIterator begin, InputIterator end,
OutputIterator oi, Tag_false, unsigned int k=5, OutputIterator oi, Tag_false, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator>* = 0) Enable_if_Polygon_2_iterator<InputIterator>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
return r_symmetric_difference(begin, end, oi, traits, k); return r_symmetric_difference(begin, end, oi, traits, k);
} }
@ -291,9 +281,8 @@ symmetric_difference(InputIterator begin, InputIterator end,
template <typename InputIterator, typename OutputIterator> template <typename InputIterator, typename OutputIterator>
inline OutputIterator inline OutputIterator
symmetric_difference(InputIterator begin, InputIterator end, symmetric_difference(InputIterator begin, InputIterator end,
OutputIterator oi, unsigned int k=5, OutputIterator oi, std::size_t k = 5,
Disable_if_Polygon_2_iterator<InputIterator>* = 0) Disable_if_Polygon_2_iterator<InputIterator>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator>::Traits traits; typename Iterator_to_gps_traits<InputIterator>::Traits traits;
return r_symmetric_difference(begin, end, oi, traits, k); return r_symmetric_difference(begin, end, oi, traits, k);
} }
@ -306,7 +295,7 @@ inline
OutputIterator symmetric_difference(InputIterator1 begin1, InputIterator1 end1, OutputIterator symmetric_difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Traits& traits, OutputIterator oi, Traits& traits,
unsigned int k=5) std::size_t k = 5)
{ return r_symmetric_difference(begin1, end1, begin2, end2, oi, traits, k); } { return r_symmetric_difference(begin1, end1, begin2, end2, oi, traits, k); }
// Without Traits // Without Traits
@ -316,7 +305,7 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator inline OutputIterator
symmetric_difference(InputIterator1 begin1, InputIterator1 end1, symmetric_difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Tag_true = Tag_true(), unsigned int k=5, OutputIterator oi, Tag_true = Tag_true(), std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator1>* = 0) Enable_if_Polygon_2_iterator<InputIterator1>* = 0)
{ return r_symmetric_difference(begin1, end1, begin2, end2, oi, k); } { return r_symmetric_difference(begin1, end1, begin2, end2, oi, k); }
@ -326,9 +315,8 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator inline OutputIterator
symmetric_difference(InputIterator1 begin1, InputIterator1 end1, symmetric_difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, Tag_false, unsigned int k=5, OutputIterator oi, Tag_false, std::size_t k = 5,
Enable_if_Polygon_2_iterator<InputIterator1>* = 0) Enable_if_Polygon_2_iterator<InputIterator1>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator1>::Traits traits; typename Iterator_to_gps_traits<InputIterator1>::Traits traits;
return r_symmetric_difference(begin1, end1, begin2, end2, oi, traits, k); return r_symmetric_difference(begin1, end1, begin2, end2, oi, traits, k);
} }
@ -339,9 +327,8 @@ template <typename InputIterator1, typename InputIterator2,
inline OutputIterator inline OutputIterator
symmetric_difference(InputIterator1 begin1, InputIterator1 end1, symmetric_difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2, InputIterator2 begin2, InputIterator2 end2,
OutputIterator oi, unsigned int k=5, OutputIterator oi, std::size_t k = 5,
Disable_if_Polygon_2_iterator<InputIterator1>* = 0) Disable_if_Polygon_2_iterator<InputIterator1>* = 0) {
{
typename Iterator_to_gps_traits<InputIterator1>::Traits traits; typename Iterator_to_gps_traits<InputIterator1>::Traits traits;
return r_symmetric_difference(begin1, end1, begin2, end2, oi, traits, k); return r_symmetric_difference(begin1, end1, begin2, end2, oi, traits, k);
} }

View File

@ -7,8 +7,8 @@
// $Id$ // $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// //
// Author(s): Baruch Zukerman <baruchzu@post.tau.ac.il> // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il> // Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_GENERAL_POLYGON_SET_2_H #ifndef CGAL_GENERAL_POLYGON_SET_2_H
#define CGAL_GENERAL_POLYGON_SET_2_H #define CGAL_GENERAL_POLYGON_SET_2_H

View File

@ -257,45 +257,25 @@ void test_CGAL_Polygon_variants()
Traits tr; Traits tr;
CGAL::do_intersect(pgn1, pgn2); CGAL::do_intersect(pgn1, pgn2);
CGAL::do_intersect(pgn1, pgn2, CGAL::Tag_true());
CGAL::do_intersect(pgn1, pgn2, CGAL::Tag_false());
CGAL::do_intersect(pgn1, pgn2, tr); CGAL::do_intersect(pgn1, pgn2, tr);
CGAL::do_intersect(pgn1, pgn_with_holes2); CGAL::do_intersect(pgn1, pgn_with_holes2);
CGAL::do_intersect(pgn1, pgn_with_holes2, CGAL::Tag_true());
CGAL::do_intersect(pgn1, pgn_with_holes2, CGAL::Tag_false());
CGAL::do_intersect(pgn1, pgn_with_holes2, tr); CGAL::do_intersect(pgn1, pgn_with_holes2, tr);
CGAL::do_intersect(pgn_with_holes1, pgn2); CGAL::do_intersect(pgn_with_holes1, pgn2);
CGAL::do_intersect(pgn_with_holes1, pgn2, CGAL::Tag_true());
CGAL::do_intersect(pgn_with_holes1, pgn2, CGAL::Tag_false());
CGAL::do_intersect(pgn_with_holes1, pgn2, tr); CGAL::do_intersect(pgn_with_holes1, pgn2, tr);
CGAL::do_intersect(pgn_with_holes1, pgn_with_holes2); CGAL::do_intersect(pgn_with_holes1, pgn_with_holes2);
CGAL::do_intersect(pgn_with_holes1, pgn_with_holes2, CGAL::Tag_true());
CGAL::do_intersect(pgn_with_holes1, pgn_with_holes2, CGAL::Tag_false());
CGAL::do_intersect(pgn_with_holes1, pgn_with_holes2, tr); CGAL::do_intersect(pgn_with_holes1, pgn_with_holes2, tr);
CGAL::do_intersect(polygons.begin(), polygons.end()); CGAL::do_intersect(polygons.begin(), polygons.end());
CGAL::do_intersect(polygons.begin(), polygons.end(), CGAL::Tag_true());
CGAL::do_intersect(polygons.begin(), polygons.end(), CGAL::Tag_false());
CGAL::do_intersect(polygons.begin(), polygons.end(), tr); CGAL::do_intersect(polygons.begin(), polygons.end(), tr);
CGAL::do_intersect(polygons_with_holes.begin(), polygons_with_holes.end()); CGAL::do_intersect(polygons_with_holes.begin(), polygons_with_holes.end());
CGAL::do_intersect(polygons_with_holes.begin(), polygons_with_holes.end(),
CGAL::Tag_true());
CGAL::do_intersect(polygons_with_holes.begin(), polygons_with_holes.end(),
CGAL::Tag_false());
CGAL::do_intersect(polygons_with_holes.begin(), polygons_with_holes.end(), tr); CGAL::do_intersect(polygons_with_holes.begin(), polygons_with_holes.end(), tr);
CGAL::do_intersect(polygons.begin(), polygons.end(), CGAL::do_intersect(polygons.begin(), polygons.end(),
polygons_with_holes.begin(), polygons_with_holes.end()); polygons_with_holes.begin(), polygons_with_holes.end());
CGAL::do_intersect(polygons.begin(), polygons.end(),
polygons_with_holes.begin(), polygons_with_holes.end(),
CGAL::Tag_true());
CGAL::do_intersect(polygons.begin(), polygons.end(),
polygons_with_holes.begin(), polygons_with_holes.end(),
CGAL::Tag_false());
CGAL::do_intersect(polygons.begin(), polygons.end(), CGAL::do_intersect(polygons.begin(), polygons.end(),
polygons_with_holes.begin(), polygons_with_holes.end(), tr); polygons_with_holes.begin(), polygons_with_holes.end(), tr);