diff --git a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Bso_internal_functions.h b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Bso_internal_functions.h index 748a0caefa6..c68d106142e 100644 --- a/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Bso_internal_functions.h +++ b/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Bso_internal_functions.h @@ -35,8 +35,7 @@ namespace CGAL { // With Traits template inline bool s_do_intersect(const Pgn1& pgn1, const Pgn2& pgn2, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn1); + General_polygon_set_2 gps(pgn1, traits); return gps.do_intersect(pgn2); } @@ -55,9 +54,8 @@ template inline bool r_do_intersect(InputIterator begin, InputIterator end, Traits& traits, unsigned int k=5) { if (begin == end) return false; - General_polygon_set_2 gps(traits); - gps.insert(*begin); - return gps.do_intersect(++begin, end, k); + General_polygon_set_2 gps(*begin, traits); + return gps.do_intersect(std::next(begin), end, k); } // Without Traits @@ -78,9 +76,8 @@ inline bool r_do_intersect(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, InputIterator2 end2, Traits& traits, unsigned int k=5) { if (begin1 == end1) return do_intersect(begin2, end2, traits, k); - General_polygon_set_2 gps(traits); - gps.insert(*begin1); - return gps.do_intersect(++begin1, end1, begin2, end2, k); + General_polygon_set_2 gps(*begin1, traits); + return gps.do_intersect(std::next(begin1), end1, begin2, end2, k); } // Without Traits @@ -106,8 +103,7 @@ inline bool r_do_intersect (InputIterator1 begin1, InputIterator1 end1, template inline Oriented_side _oriented_side(const Obj& obj, const Pgn& pgn, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn); + General_polygon_set_2 gps(pgn, traits); return gps.oriented_side(obj); } @@ -142,8 +138,7 @@ inline Oriented_side _oriented_side(const Pgn1& pgn1, const Pgn2& pgn2) template inline OutputIterator s_intersection(const Pgn1& pgn1, const Pgn2& pgn2, OutputIterator oi, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn1); + General_polygon_set_2 gps(pgn1, traits); gps.intersection(pgn2); return gps.polygons_with_holes(oi); } @@ -169,11 +164,11 @@ inline OutputIterator s_intersection(const Pgn1& pgn1, const Pgn2& pgn2, // With Traits template inline OutputIterator r_intersection(InputIterator begin, InputIterator end, - OutputIterator oi, Traits&, + OutputIterator oi, Traits& traits, unsigned int k=5) { if (begin == end) return (oi); - General_polygon_set_2 gps(*begin); - gps.intersection(++begin, end, k); + General_polygon_set_2 gps(*begin, traits); + gps.intersection(std::next(begin), end, k); return gps.polygons_with_holes(oi); } @@ -198,8 +193,8 @@ inline OutputIterator r_intersection(InputIterator1 begin1, InputIterator1 end1, OutputIterator oi, Traits& traits, unsigned int k=5) { if (begin1 == end1) return r_intersection(begin2, end2, oi, traits, k); - General_polygon_set_2 gps(*begin1); - gps.intersection(++begin1, end1, begin2, end2, k); + General_polygon_set_2 gps(*begin1, traits); + gps.intersection(std::next(begin1), end1, begin2, end2, k); return gps.polygons_with_holes(oi); } @@ -251,8 +246,7 @@ inline bool s_join(const Pgn1& pgn1, const Pgn2& pgn2, typename Traits::Polygon_with_holes_2& res, Traits& traits) { if (_is_empty(pgn1, traits) || _is_empty(pgn2, traits)) return false; - General_polygon_set_2 gps(traits); - gps.insert(pgn1); + General_polygon_set_2 gps(pgn1, traits); gps.join(pgn2); if (gps.number_of_polygons_with_holes() == 1) { Oneset_iterator oi(res); @@ -287,10 +281,11 @@ inline bool s_join(const Pgn1& pgn1, const Pgn2& pgn2, Pwh& pwh) { // With traits template inline OutputIterator r_join(InputIterator begin, InputIterator end, - OutputIterator oi, Traits&, unsigned int k=5) { + OutputIterator oi, Traits& traits, + unsigned int k=5) { if (begin == end) return oi; - General_polygon_set_2 gps(*begin); - gps.join(++begin, end, k); + General_polygon_set_2 gps(*begin, traits); + gps.join(std::next(begin), end, k); return gps.polygons_with_holes(oi); } @@ -315,8 +310,8 @@ inline OutputIterator r_join(InputIterator1 begin1, InputIterator1 end1, OutputIterator oi, Traits& traits, unsigned int k=5) { if (begin1 == end1) return r_join(begin2, end2, oi, traits, k); - General_polygon_set_2 gps(*begin1); - gps.join(++begin1, end1, begin2, end2, k); + General_polygon_set_2 gps(*begin1, traits); + gps.join(std::next(begin1), end1, begin2, end2, k); return gps.polygons_with_holes(oi); } @@ -344,8 +339,7 @@ inline OutputIterator r_join(InputIterator1 begin1, InputIterator1 end1, template inline OutputIterator _difference(const Pgn1& pgn1, const Pgn2& pgn2, OutputIterator oi, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn1); + General_polygon_set_2 gps(pgn1, traits); gps.difference(pgn2); return gps.polygons_with_holes(oi); } @@ -377,8 +371,7 @@ template gps(traits); - gps.insert(pgn1); + General_polygon_set_2 gps(pgn1, traits); gps.symmetric_difference(pgn2); return gps.polygons_with_holes(oi); } @@ -408,9 +401,8 @@ OutputIterator r_symmetric_difference(InputIterator begin, InputIterator end, OutputIterator oi, Traits& traits, unsigned int k=5) { if (begin == end) return (oi); - General_polygon_set_2 gps(traits); - gps.insert(*begin); - gps.symmetric_difference(++begin, end, k); + General_polygon_set_2 gps(*begin, traits); + gps.symmetric_difference(std::next(begin), end, k); return gps.polygons_with_holes(oi); } @@ -441,9 +433,8 @@ inline OutputIterator r_symmetric_difference(InputIterator1 begin1, unsigned int k=5) { if (begin1 == end1) return r_symmetric_difference(begin2, end2, oi, traits, k); - General_polygon_set_2 gps(traits); - gps.insert(*begin1); - gps.symmetric_difference(++begin1, end1, begin2, end2, k); + General_polygon_set_2 gps(*begin1, traits); + gps.symmetric_difference(std::next(begin1), end1, begin2, end2, k); return gps.polygons_with_holes(oi); } @@ -475,8 +466,7 @@ inline OutputIterator r_symmetric_difference(InputIterator1 begin1, template void _complement(const Polygon_2& pgn, typename Traits::Polygon_with_holes_2& res, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn); + General_polygon_set_2 gps(pgn, traits); gps.complement(); Oneset_iterator oi(res); gps.polygons_with_holes(oi); @@ -486,8 +476,7 @@ void _complement(const Polygon_2& pgn, template void _complement(const General_polygon_2& pgn, typename Traits::Polygon_with_holes_2& res, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn); + General_polygon_set_2 gps(pgn, traits); gps.complement(); Oneset_iterator oi(res); gps.polygons_with_holes(oi); @@ -498,8 +487,7 @@ template OutputIterator _complement(const Polygon_with_holes_2& pgn, OutputIterator oi, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn); + General_polygon_set_2 gps(pgn, traits); gps.complement(); return gps.polygons_with_holes(oi); } @@ -508,8 +496,7 @@ OutputIterator _complement(const Polygon_with_holes_2& pgn, template OutputIterator _complement(const General_polygon_with_holes_2& pgn, OutputIterator oi, Traits& traits) { - General_polygon_set_2 gps(traits); - gps.insert(pgn); + General_polygon_set_2 gps(pgn, traits); gps.complement(); return gps.polygons_with_holes(oi); } diff --git a/Boolean_set_operations_2/include/CGAL/General_polygon_set_2.h b/Boolean_set_operations_2/include/CGAL/General_polygon_set_2.h index c6347c83969..ade9a4989e5 100644 --- a/Boolean_set_operations_2/include/CGAL/General_polygon_set_2.h +++ b/Boolean_set_operations_2/include/CGAL/General_polygon_set_2.h @@ -50,13 +50,24 @@ public: // default costructor General_polygon_set_2() : Base() {} - // constructor with traits object - General_polygon_set_2(const Traits_2& tr) : Base(tr) {} + // constructor from a traits object + General_polygon_set_2(const Traits_2& traits) : Base(traits) {} + // constructor from a polygon explicit General_polygon_set_2(const Polygon_2& pgn) : Base(pgn) {} - explicit General_polygon_set_2(const Polygon_with_holes_2& pgn_with_holes): - Base(pgn_with_holes) + // constructor from a polygon with holes + explicit General_polygon_set_2(const Polygon_with_holes_2& pwh) : Base(pwh) {} + + // constructor from a polygon and a traits object + explicit General_polygon_set_2(const Polygon_2& pgn, const Traits_2& traits) : + Base(pgn, traits) + {} + + // constructor from a polygon with holes and a traits object + explicit General_polygon_set_2(const Polygon_with_holes_2& pwh, + const Traits_2& traits) : + Base(pwh, traits) {} // For some reason the below functions (the ones that we call "using" for) @@ -92,17 +103,13 @@ public: * \return the underlying arrangement. */ const Arrangement_2& arrangement() const - { - return *(static_cast(this->m_arr)); - } + { return *(static_cast(this->m_arr)); } /*! Obtain a reference to the underlying arrangement * \return the underlying arrangement. */ Arrangement_2& arrangement() - { - return *(static_cast(this->m_arr)); - } + { return *(static_cast(this->m_arr)); } //@} }; diff --git a/Boolean_set_operations_2/include/CGAL/General_polygon_set_on_surface_2.h b/Boolean_set_operations_2/include/CGAL/General_polygon_set_on_surface_2.h index 1369b2a348a..7081d319aa8 100644 --- a/Boolean_set_operations_2/include/CGAL/General_polygon_set_on_surface_2.h +++ b/Boolean_set_operations_2/include/CGAL/General_polygon_set_on_surface_2.h @@ -23,7 +23,6 @@ namespace CGAL { - namespace Boolean_set_operation_2_internal { struct PreconditionValidationPolicy @@ -43,7 +42,6 @@ namespace Boolean_set_operation_2_internal }; } - // General_polygon_set_on_surface_2 /* This class is derived from Gps_on_surface_base_2. @@ -74,48 +72,55 @@ public: General_polygon_set_on_surface_2() : Base() {} - // constructor with traits object - General_polygon_set_on_surface_2(const Traits_2& tr) : Base(tr) {} + // constructor from a traits object + General_polygon_set_on_surface_2(const Traits_2& traits) : Base(traits) {} + // copy constructor General_polygon_set_on_surface_2(const Self& ps) : Base(ps) {} + // assignment operator General_polygon_set_on_surface_2& operator=(const Self& ps) { Base::operator=(ps); return (*this); } + // constructor from a polygon explicit General_polygon_set_on_surface_2(const Polygon_2& pgn) : Base(pgn) {} + // constructor from a polygon with holes explicit - General_polygon_set_on_surface_2(const Polygon_with_holes_2& pgn_with_holes) : - Base(pgn_with_holes) + General_polygon_set_on_surface_2(const Polygon_with_holes_2& pwh) : + Base(pwh) + {} + + // constructor from a polygon and a traits object + explicit General_polygon_set_on_surface_2(const Polygon_2& pgn, + const Traits_2& traits) : + Base(pgn, traits) {} + + // constructor from a polygon with holes and a traits object + explicit + General_polygon_set_on_surface_2(const Polygon_with_holes_2& pwh, + const Traits_2& traits) : + Base(pwh, traits) {} protected: - General_polygon_set_on_surface_2(Arrangement_on_surface_2* arr) : Base(arr) - {} + General_polygon_set_on_surface_2(Arrangement_on_surface_2* arr) : Base(arr) {} public: - //destructor - virtual ~General_polygon_set_on_surface_2() - {} + // destructor + virtual ~General_polygon_set_on_surface_2() {} void intersection(const Self& gps1, const Self& gps2) - { - Base::intersection(gps1.base(), gps2.base()); - } + { Base::intersection(gps1.base(), gps2.base()); } void join(const Self& gps1, const Self& gps2) - { - Base::join(gps1.base(), gps2.base()); - } + { Base::join(gps1.base(), gps2.base()); } void symmetric_difference(const Self& gps1, const Self& gps2) - { - Base::symmetric_difference(gps1.base(), gps2.base()); - } - + { Base::symmetric_difference(gps1.base(), gps2.base()); } // For some reason the below functions (the ones that we call "using" for) // are hidden by the function in this class and are not found in the parent's @@ -128,16 +133,9 @@ public: using Base::symmetric_difference; private: - const Base& base() const - { - return static_cast (*this); - } - - Base& base() - { - return static_cast (*this); - } + const Base& base() const { return static_cast (*this); } + Base& base() { return static_cast (*this); } }; } //namespace CGAL