mirror of https://github.com/CGAL/cgal
Added missing constructors (from polygon + traits) and used them
This commit is contained in:
parent
514f123a75
commit
76f44656eb
|
|
@ -35,8 +35,7 @@ namespace CGAL {
|
|||
// With Traits
|
||||
template <typename Pgn1, class Pgn2, typename Traits>
|
||||
inline bool s_do_intersect(const Pgn1& pgn1, const Pgn2& pgn2, Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn1);
|
||||
General_polygon_set_2<Traits> gps(pgn1, traits);
|
||||
return gps.do_intersect(pgn2);
|
||||
}
|
||||
|
||||
|
|
@ -55,9 +54,8 @@ template <typename InputIterator, typename Traits>
|
|||
inline bool r_do_intersect(InputIterator begin, InputIterator end,
|
||||
Traits& traits, unsigned int k=5) {
|
||||
if (begin == end) return false;
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(*begin);
|
||||
return gps.do_intersect(++begin, end, k);
|
||||
General_polygon_set_2<Traits> 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<Traits> gps(traits);
|
||||
gps.insert(*begin1);
|
||||
return gps.do_intersect(++begin1, end1, begin2, end2, k);
|
||||
General_polygon_set_2<Traits> 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 <typename Obj, typename Pgn, typename Traits>
|
||||
inline Oriented_side _oriented_side(const Obj& obj, const Pgn& pgn,
|
||||
Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn);
|
||||
General_polygon_set_2<Traits> gps(pgn, traits);
|
||||
return gps.oriented_side(obj);
|
||||
}
|
||||
|
||||
|
|
@ -142,8 +138,7 @@ inline Oriented_side _oriented_side(const Pgn1& pgn1, const Pgn2& pgn2)
|
|||
template <typename Pgn1, typename Pgn2, typename OutputIterator, typename Traits>
|
||||
inline OutputIterator s_intersection(const Pgn1& pgn1, const Pgn2& pgn2,
|
||||
OutputIterator oi, Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn1);
|
||||
General_polygon_set_2<Traits> 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 <typename InputIterator, typename OutputIterator, typename Traits>
|
||||
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<Traits> gps(*begin);
|
||||
gps.intersection(++begin, end, k);
|
||||
General_polygon_set_2<Traits> 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<Traits> gps(*begin1);
|
||||
gps.intersection(++begin1, end1, begin2, end2, k);
|
||||
General_polygon_set_2<Traits> 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<Traits> gps(traits);
|
||||
gps.insert(pgn1);
|
||||
General_polygon_set_2<Traits> gps(pgn1, traits);
|
||||
gps.join(pgn2);
|
||||
if (gps.number_of_polygons_with_holes() == 1) {
|
||||
Oneset_iterator<typename Traits::Polygon_with_holes_2> oi(res);
|
||||
|
|
@ -287,10 +281,11 @@ inline bool s_join(const Pgn1& pgn1, const Pgn2& pgn2, Pwh& pwh) {
|
|||
// With traits
|
||||
template <typename InputIterator, typename OutputIterator, typename Traits>
|
||||
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<Traits> gps(*begin);
|
||||
gps.join(++begin, end, k);
|
||||
General_polygon_set_2<Traits> 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<Traits> gps(*begin1);
|
||||
gps.join(++begin1, end1, begin2, end2, k);
|
||||
General_polygon_set_2<Traits> 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 <typename Pgn1, typename Pgn2, typename OutputIterator, typename Traits>
|
||||
inline OutputIterator _difference(const Pgn1& pgn1, const Pgn2& pgn2,
|
||||
OutputIterator oi, Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn1);
|
||||
General_polygon_set_2<Traits> gps(pgn1, traits);
|
||||
gps.difference(pgn2);
|
||||
return gps.polygons_with_holes(oi);
|
||||
}
|
||||
|
|
@ -377,8 +371,7 @@ template <typename Pgn1, typename Pgn2, typename OutputIterator, typename Traits
|
|||
inline OutputIterator s_symmetric_difference(const Pgn1& pgn1, const Pgn2& pgn2,
|
||||
OutputIterator oi,
|
||||
Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn1);
|
||||
General_polygon_set_2<Traits> 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<Traits> gps(traits);
|
||||
gps.insert(*begin);
|
||||
gps.symmetric_difference(++begin, end, k);
|
||||
General_polygon_set_2<Traits> 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<Traits> gps(traits);
|
||||
gps.insert(*begin1);
|
||||
gps.symmetric_difference(++begin1, end1, begin2, end2, k);
|
||||
General_polygon_set_2<Traits> 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 <typename Kernel, typename Container, typename Traits>
|
||||
void _complement(const Polygon_2<Kernel, Container>& pgn,
|
||||
typename Traits::Polygon_with_holes_2& res, Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn);
|
||||
General_polygon_set_2<Traits> gps(pgn, traits);
|
||||
gps.complement();
|
||||
Oneset_iterator<typename Traits::Polygon_with_holes_2> oi(res);
|
||||
gps.polygons_with_holes(oi);
|
||||
|
|
@ -486,8 +476,7 @@ void _complement(const Polygon_2<Kernel, Container>& pgn,
|
|||
template <typename ArrTraits, typename Traits>
|
||||
void _complement(const General_polygon_2<ArrTraits>& pgn,
|
||||
typename Traits::Polygon_with_holes_2& res, Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn);
|
||||
General_polygon_set_2<Traits> gps(pgn, traits);
|
||||
gps.complement();
|
||||
Oneset_iterator<typename Traits::Polygon_with_holes_2> oi(res);
|
||||
gps.polygons_with_holes(oi);
|
||||
|
|
@ -498,8 +487,7 @@ template <typename Kernel, typename Container, typename OutputIterator,
|
|||
typename Traits>
|
||||
OutputIterator _complement(const Polygon_with_holes_2<Kernel, Container>& pgn,
|
||||
OutputIterator oi, Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn);
|
||||
General_polygon_set_2<Traits> gps(pgn, traits);
|
||||
gps.complement();
|
||||
return gps.polygons_with_holes(oi);
|
||||
}
|
||||
|
|
@ -508,8 +496,7 @@ OutputIterator _complement(const Polygon_with_holes_2<Kernel, Container>& pgn,
|
|||
template <typename Pgn, typename OutputIterator, typename Traits>
|
||||
OutputIterator _complement(const General_polygon_with_holes_2<Pgn>& pgn,
|
||||
OutputIterator oi, Traits& traits) {
|
||||
General_polygon_set_2<Traits> gps(traits);
|
||||
gps.insert(pgn);
|
||||
General_polygon_set_2<Traits> gps(pgn, traits);
|
||||
gps.complement();
|
||||
return gps.polygons_with_holes(oi);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<const Arrangement_2*>(this->m_arr));
|
||||
}
|
||||
{ return *(static_cast<const Arrangement_2*>(this->m_arr)); }
|
||||
|
||||
/*! Obtain a reference to the underlying arrangement
|
||||
* \return the underlying arrangement.
|
||||
*/
|
||||
Arrangement_2& arrangement()
|
||||
{
|
||||
return *(static_cast<Arrangement_2*>(this->m_arr));
|
||||
}
|
||||
{ return *(static_cast<Arrangement_2*>(this->m_arr)); }
|
||||
|
||||
//@}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<const Base&> (*this);
|
||||
}
|
||||
|
||||
Base& base()
|
||||
{
|
||||
return static_cast<Base&> (*this);
|
||||
}
|
||||
const Base& base() const { return static_cast<const Base&> (*this); }
|
||||
|
||||
Base& base() { return static_cast<Base&> (*this); }
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
Loading…
Reference in New Issue