added dcel template

This commit is contained in:
Efi Fogel 2007-01-10 17:30:22 +00:00
parent f3699526e1
commit 9a83a5f864
3 changed files with 870 additions and 932 deletions

View File

@ -25,15 +25,13 @@
#include <CGAL/function_objects.h>
#include <CGAL/circulator.h>
#include <CGAL/Boolean_set_operations_2/Gps_bfs_scanner.h>
#include <CGAL/Boolean_set_operations_2/Gps_dcel.h>
#include <CGAL/Arr_accessor.h>
#include <queue>
template <class Traits_>
void General_polygon_set_2<Traits_>::
construct_polygon(Ccb_halfedge_const_circulator ccb,
Polygon_2& pgn,
template <class Traits_, class Dcel_>
void General_polygon_set_2<Traits_, Dcel_>::
construct_polygon(Ccb_halfedge_const_circulator ccb, Polygon_2 & pgn,
Traits_ * tr)
{
typedef CGAL::Ccb_curve_iterator<Arrangement_2> Ccb_curve_iterator;
@ -48,8 +46,8 @@ template <class Arrangement, class OutputIterator>
class Arr_bfs_scanner
{
public:
typedef typename Arrangement::Traits_2 Gps_traits;
typedef typename Arrangement::Dcel My_gps_dcel;
typedef typename Gps_traits::Polygon_2 Polygon_2;
typedef typename Gps_traits::Polygon_with_holes_2 Polygon_with_holes_2;
typedef typename Arrangement::Ccb_halfedge_const_circulator
@ -123,7 +121,8 @@ public:
void scan_ccb(Ccb_halfedge_const_circulator ccb)
{
Polygon_2 pgn_boundary;
General_polygon_set_2<Gps_traits>::construct_polygon(ccb, pgn_boundary, m_traits);
General_polygon_set_2<Gps_traits, My_gps_dcel>::
construct_polygon(ccb, pgn_boundary, m_traits);
Ccb_halfedge_const_circulator ccb_end = ccb;
do
@ -166,7 +165,8 @@ public:
if (!f->contained())
{
m_pgn_holes.push_back(Polygon_2());
General_polygon_set_2<Gps_traits>::construct_polygon(f->outer_ccb(), m_pgn_holes.back(), m_traits);
General_polygon_set_2<Gps_traits, My_gps_dcel>::
construct_polygon(f->outer_ccb(), m_pgn_holes.back(), m_traits);
m_holes_q.push(f);
}
@ -199,8 +199,9 @@ public:
CGAL_assertion(!he->twin()->face()->contained());
m_pgn_holes.push_back(Polygon_2());
General_polygon_set_2<Gps_traits>::construct_polygon
(he->twin()->face()->outer_ccb(), m_pgn_holes.back(), m_traits);
General_polygon_set_2<Gps_traits, My_gps_dcel>::
construct_polygon(he->twin()->face()->outer_ccb(),
m_pgn_holes.back(), m_traits);
m_holes_q.push(he->twin()->face());
}
@ -256,18 +257,17 @@ public:
}
};
template < class Traits_>
void General_polygon_set_2<Traits_>::_insert(const Polygon_2& pgn, Arrangement_2& arr)
template <class Traits_, class Dcel_>
void General_polygon_set_2<Traits_, Dcel_>::
_insert(const Polygon_2& pgn, Arrangement_2 & arr)
{
CGAL_precondition(m_traits->is_valid_2_object()(pgn));
typedef Arr_accessor<Arrangement_2> Arr_accessor;
Arr_accessor accessor(arr);
Compare_endpoints_xy_2 cmp_ends =
m_traits->compare_endpoints_xy_2_object();
Compare_endpoints_xy_2 cmp_ends = m_traits->compare_endpoints_xy_2_object();
std::pair<Curve_const_iterator,
Curve_const_iterator> itr_pair =
std::pair<Curve_const_iterator, Curve_const_iterator> itr_pair =
m_traits->construct_curves_2_object()(pgn);
if (itr_pair.first == itr_pair.second)
@ -365,21 +365,20 @@ void General_polygon_set_2<Traits_>::_insert(const Polygon_2& pgn, Arrangement_2
}
template < class Traits_ >
template <class Traits_, class Dcel_>
template<class PolygonIter >
void General_polygon_set_2<Traits_>::insert(PolygonIter p_begin,
PolygonIter p_end)
void General_polygon_set_2<Traits_, Dcel_>::
insert(PolygonIter p_begin, PolygonIter p_end)
{
typename std::iterator_traits<PolygonIter>::value_type pgn;
_insert(p_begin, p_end, pgn);
}
template < class Traits_ >
template <class Traits_, class Dcel_>
template<class PolygonIter, class PolygonWithHolesIter>
void General_polygon_set_2<Traits_>::insert(PolygonIter p_begin,
PolygonIter p_end,
PolygonWithHolesIter pwh_begin,
PolygonWithHolesIter pwh_end)
void General_polygon_set_2<Traits_, Dcel_>::
insert(PolygonIter p_begin, PolygonIter p_end,
PolygonWithHolesIter pwh_begin, PolygonWithHolesIter pwh_end)
{
typedef std::list<X_monotone_curve_2> XCurveList;
typedef Init_faces_visitor<Arrangement_2> My_visitor;
@ -412,11 +411,10 @@ void General_polygon_set_2<Traits_>::insert(PolygonIter p_begin,
}
//insert a range of simple polygons to the arrangement
template < class Traits_ >
template <class Traits_, class Dcel_>
template<class PolygonIter>
void General_polygon_set_2<Traits_>::_insert(PolygonIter p_begin,
PolygonIter p_end,
Polygon_2& /*pgn*/)
void General_polygon_set_2<Traits_, Dcel_>::
_insert(PolygonIter p_begin, PolygonIter p_end, Polygon_2 & /*pgn*/)
{
for(PolygonIter pitr = p_begin; pitr != p_end; ++pitr)
{
@ -425,11 +423,10 @@ void General_polygon_set_2<Traits_>::_insert(PolygonIter p_begin,
}
}
template < class Traits_ >
template <class Traits_, class Dcel_>
template<class PolygonIter>
void General_polygon_set_2<Traits_>::_insert(PolygonIter p_begin,
PolygonIter p_end,
Polygon_with_holes_2& /*pgn*/)
void General_polygon_set_2<Traits_, Dcel_>::
_insert(PolygonIter p_begin, PolygonIter p_end, Polygon_with_holes_2 & /*pgn*/)
{
typedef std::list<X_monotone_curve_2> XCurveList;
typedef Init_faces_visitor<Arrangement_2> My_visitor;
@ -460,8 +457,9 @@ void General_polygon_set_2<Traits_>::_insert(PolygonIter p_begin,
//insert non-sipmle poloygons with holes (non incident edges may have
// common vertex, but they dont intersect at their interior
template <class Traits_>
void General_polygon_set_2<Traits_>::_insert (const Polygon_with_holes_2& pgn, Arrangement_2& arr)
template <class Traits_, class Dcel_>
void General_polygon_set_2<Traits_, Dcel_>::
_insert(const Polygon_with_holes_2 & pgn, Arrangement_2 & arr)
{
CGAL_precondition(m_traits->is_valid_2_object()(pgn));
typedef std::list<X_monotone_curve_2> XCurveList;
@ -481,11 +479,11 @@ void General_polygon_set_2<Traits_>::_insert (const Polygon_with_holes_2& pgn, A
_reset_faces(&arr);
}
template <class Traits_>
template <class Traits_, class Dcel_>
template <class OutputIterator>
void
General_polygon_set_2<Traits_>::_construct_curves(const Polygon_2& pgn,
OutputIterator oi)
General_polygon_set_2<Traits_, Dcel_>::
_construct_curves(const Polygon_2 & pgn, OutputIterator oi)
{
std::pair<Curve_const_iterator,
Curve_const_iterator> itr_pair =
@ -493,11 +491,11 @@ void
std::copy (itr_pair.first, itr_pair.second, oi);
}
template <class Traits_>
template <class Traits_, class Dcel_>
template <class OutputIterator>
void
General_polygon_set_2<Traits_>::_construct_curves(const Polygon_with_holes_2& pgn,
OutputIterator oi)
General_polygon_set_2<Traits_, Dcel_>::
_construct_curves(const Polygon_with_holes_2 & pgn, OutputIterator oi)
{
if (!pgn.is_unbounded())
{
@ -519,10 +517,11 @@ General_polygon_set_2<Traits_>::_construct_curves(const Polygon_with_holes_2& pg
}
}
template <class Traits_>
template <class Traits_, class Dcel_>
template <class OutputIterator>
OutputIterator
General_polygon_set_2<Traits_>::polygons_with_holes(OutputIterator out) const
General_polygon_set_2<Traits_, Dcel_>::
polygons_with_holes(OutputIterator out) const
{
typedef Arr_bfs_scanner<Arrangement_2, OutputIterator> Arr_bfs_scanner;
Arr_bfs_scanner scanner(this->m_traits, out);
@ -531,19 +530,22 @@ template <class Traits_>
}
template < class Traits_ >
typename General_polygon_set_2<Traits_>::Size
General_polygon_set_2<Traits_>::number_of_polygons_with_holes() const
template <class Traits_, class Dcel_>
typename General_polygon_set_2<Traits_, Dcel_>::Size
General_polygon_set_2<Traits_, Dcel_>::
number_of_polygons_with_holes() const
{
typedef Arr_bfs_scanner<Arrangement_2, Counting_output_iterator> Arr_bfs_scanner;
typedef Arr_bfs_scanner<Arrangement_2, Counting_output_iterator>
Arr_bfs_scanner;
Counting_output_iterator coi;
Arr_bfs_scanner scanner(this->m_traits, coi);
scanner.scan(*(this->m_arr));
return (scanner.output_iterator().current_counter());
}
template < class Traits_ >
bool General_polygon_set_2<Traits_>::locate(const Point_2& q, Polygon_with_holes_2& pgn) const
template <class Traits_, class Dcel_>
bool General_polygon_set_2<Traits_, Dcel_>::
locate(const Point_2& q, Polygon_with_holes_2& pgn) const
{
Walk_pl pl(*m_arr);
@ -610,9 +612,10 @@ bool General_polygon_set_2<Traits_>::locate(const Point_2& q, Polygon_with_holes
return true;
}
template < class Traits_ >
typename General_polygon_set_2<Traits_>::Ccb_halfedge_const_circulator
General_polygon_set_2<Traits_>::get_boundary_of_polygon(Face_const_iterator f) const
template <class Traits_, class Dcel_>
typename General_polygon_set_2<Traits_, Dcel_>::Ccb_halfedge_const_circulator
General_polygon_set_2<Traits_, Dcel_>::
get_boundary_of_polygon(Face_const_iterator f) const
{
CGAL_assertion(!f->visited());
f->set_visited(true);
@ -642,10 +645,9 @@ typename General_polygon_set_2<Traits_>::Ccb_halfedge_const_circulator
}
template < class Traits_ >
bool General_polygon_set_2<Traits_>::
is_hole_of_face(Face_const_handle f,
Halfedge_const_handle he) const
template <class Traits_, class Dcel_>
bool General_polygon_set_2<Traits_, Dcel_>::
is_hole_of_face(Face_const_handle f, Halfedge_const_handle he) const
{
Hole_const_iterator holes_it;
for (holes_it = f->holes_begin(); holes_it != f->holes_end(); ++holes_it)

View File

@ -16,10 +16,20 @@
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_GENERAL_POLYGON_SET_2_H
#define CGAL_GENERAL_POLYGON_SET_2_H
#include <CGAL/basic.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <CGAL/iterator.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Arr_overlay.h>
#include <CGAL/Boolean_set_operations_2/Gps_dcel.h>
#include <CGAL/Boolean_set_operations_2/Gps_do_intersect_functor.h>
#include <CGAL/Boolean_set_operations_2/Gps_intersection_functor.h>
@ -27,32 +37,21 @@
#include <CGAL/Boolean_set_operations_2/Gps_difference_functor.h>
#include <CGAL/Boolean_set_operations_2/Gps_sym_diff_functor.h>
#include <CGAL/Boolean_set_operations_2/Gps_merge.h>
#include <CGAL/Boolean_set_operations_2/Gps_polygon_simplifier.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Arr_overlay.h>
#include <CGAL/Kernel_traits.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <CGAL/iterator.h>
#include <CGAL/Boolean_set_operations_2/Ccb_curve_iterator.h>
CGAL_BEGIN_NAMESPACE
// General_polygon_set_2
template < class Traits_ >
template <class Traits_, class Dcel_ = Gps_dcel<Traits_> >
class General_polygon_set_2
{
public:
typedef Traits_ Traits_2;
typedef Dcel_ Dcel;
typedef typename Traits_2::Polygon_2 Polygon_2;
typedef typename Traits_2::Polygon_with_holes_2 Polygon_with_holes_2;
typedef Arrangement_2<Traits_2, Gps_dcel<Traits_2> > Arrangement_2;
typedef Arrangement_2<Traits_2, Dcel> Arrangement_2;
typedef std::size_t Size;
private:
@ -63,11 +62,13 @@ private:
typedef typename Polygon_with_holes_2::Hole_const_iterator
GP_Holes_const_iterator;
typedef typename Traits_2::Curve_const_iterator Curve_const_iterator;
typedef typename Traits_2::Compare_endpoints_xy_2 Compare_endpoints_xy_2;
typedef typename Traits_2::Compare_endpoints_xy_2
Compare_endpoints_xy_2;
typedef typename Traits_2::Construct_opposite_2 Construct_opposite_2;
typedef typename Arrangement_2::Face_const_iterator Face_const_iterator;
typedef typename Arrangement_2::Halfedge_const_iterator Halfedge_const_iterator;
typedef typename Arrangement_2::Halfedge_const_iterator
Halfedge_const_iterator;
typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
typedef typename Arrangement_2::Edge_const_iterator Edge_const_iterator;
typedef typename Arrangement_2::Hole_const_iterator Hole_const_iterator;
@ -120,7 +121,8 @@ public:
{}
General_polygon_set_2(const Self& ps): m_traits(new Traits_2(*(ps.m_traits))),
General_polygon_set_2(const Self& ps) :
m_traits(new Traits_2(*(ps.m_traits))),
m_traits_owner(true),
m_arr(new Arrangement_2(*(ps.m_arr)))
{}
@ -166,9 +168,6 @@ private:
{}
public:
//destructor
virtual ~General_polygon_set_2()
{
@ -222,13 +221,10 @@ private:
// precondition: the first range is disjoint simple polygons
// the second range is disjoint polygons with holes
template <class PolygonIterator, class PolygonWithHolesIterator>
void insert(PolygonIterator pgn_begin,
PolygonIterator pgn_end,
void insert(PolygonIterator pgn_begin, PolygonIterator pgn_end,
PolygonWithHolesIterator pgn_with_holes_begin,
PolygonWithHolesIterator pgn_with_holes_end);
// test for intersection with a simple polygon
bool do_intersect(const Polygon_2 &pgn) const
{
@ -608,13 +604,10 @@ inline void join(InputIterator begin,
delete arr_vec[0].second;
}
//join range of polygons with holes
template <class InputIterator>
inline void join(InputIterator begin,
InputIterator end,
Polygon_with_holes_2& pgn,
unsigned int k=5)
inline void join(InputIterator begin, InputIterator end,
Polygon_with_holes_2& pgn, unsigned int k=5)
{
std::vector<Arr_entry> arr_vec (std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr;
@ -636,10 +629,8 @@ inline void join(InputIterator begin,
}
template <class InputIterator1, class InputIterator2>
inline void join(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2,
inline void join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
unsigned int k=5)
{
std::vector<Arr_entry> arr_vec (std::distance(begin1, end1)+
@ -674,7 +665,8 @@ inline void join(InputIterator1 begin1,
// intersect range of polygins
template <class InputIterator>
inline void intersection(InputIterator begin, InputIterator end, unsigned int k=5)
inline void intersection(InputIterator begin, InputIterator end,
unsigned int k=5)
{
typename std::iterator_traits<InputIterator>::value_type pgn;
this->intersection(begin, end, pgn, k);
@ -685,10 +677,8 @@ inline void intersection(InputIterator begin, InputIterator end, unsigned int k=
// intersect range of simple polygons
template <class InputIterator>
inline void intersection(InputIterator begin,
InputIterator end,
Polygon_2& pgn,
unsigned int k)
inline void intersection(InputIterator begin, InputIterator end,
Polygon_2& pgn, unsigned int k)
{
std::vector<Arr_entry> arr_vec (std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr;
@ -712,10 +702,8 @@ inline void intersection(InputIterator begin,
//intersect range of polygons with holes
template <class InputIterator>
inline void intersection(InputIterator begin,
InputIterator end,
Polygon_with_holes_2& pgn,
unsigned int k)
inline void intersection(InputIterator begin, InputIterator end,
Polygon_with_holes_2& pgn, unsigned int k)
{
std::vector<Arr_entry> arr_vec (std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr;
@ -739,10 +727,8 @@ inline void intersection(InputIterator begin,
template <class InputIterator1, class InputIterator2>
inline void intersection(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2,
inline void intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
unsigned int k=5)
{
std::vector<Arr_entry> arr_vec (std::distance(begin1, end1)+
@ -791,10 +777,8 @@ inline void symmetric_difference(InputIterator begin, InputIterator end,
// intersect range of simple polygons
template <class InputIterator>
inline void symmetric_difference(InputIterator begin,
InputIterator end,
Polygon_2& pgn,
unsigned int k=5)
inline void symmetric_difference(InputIterator begin, InputIterator end,
Polygon_2& pgn, unsigned int k=5)
{
std::vector<Arr_entry> arr_vec (std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr;
@ -818,10 +802,8 @@ inline void symmetric_difference(InputIterator begin,
//intersect range of polygons with holes
template <class InputIterator>
inline void symmetric_difference(InputIterator begin,
InputIterator end,
Polygon_with_holes_2& pgn,
unsigned int k=5)
inline void symmetric_difference(InputIterator begin, InputIterator end,
Polygon_with_holes_2& pgn, unsigned int k=5)
{
std::vector<Arr_entry> arr_vec (std::distance(begin, end) + 1);
arr_vec[0].first = this->m_arr;
@ -845,10 +827,8 @@ inline void symmetric_difference(InputIterator begin,
template <class InputIterator1, class InputIterator2>
inline void symmetric_difference(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2,
inline void symmetric_difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
unsigned int k=5)
{
std::vector<Arr_entry> arr_vec (std::distance(begin1, end1)+
@ -881,17 +861,13 @@ inline void symmetric_difference(InputIterator1 begin1,
this->_reset_faces();
}
static void construct_polygon(Ccb_halfedge_const_circulator ccb,
Polygon_2& pgn,
Traits_2* tr);
Polygon_2 & pgn, Traits_2 * tr);
bool is_hole_of_face(Face_const_handle f, Halfedge_const_handle he) const;
bool is_hole_of_face(Face_const_handle f,
Halfedge_const_handle he) const;
Ccb_halfedge_const_circulator get_boundary_of_polygon(Face_const_iterator f) const;
Ccb_halfedge_const_circulator
get_boundary_of_polygon(Face_const_iterator f) const;
void remove_redundant_edges()
{
@ -900,8 +876,7 @@ void remove_redundant_edges()
void _remove_redundant_edges(Arrangement_2* arr)
{
for(Edge_iterator itr = arr->edges_begin();
itr != arr->edges_end(); )
for (Edge_iterator itr = arr->edges_begin(); itr != arr->edges_end(); )
{
Halfedge_handle he = itr;
if (he->face()->contained() == he->twin()->face()->contained())
@ -956,19 +931,16 @@ void _build_sorted_vertices_vectors (std::vector<Arr_entry>& arr_vec)
}
// Sort the vector.
std::sort (arr_vec[i].second->begin(), arr_vec[i].second->end(),
comp);
std::sort (arr_vec[i].second->begin(), arr_vec[i].second->end(), comp);
}
return;
}
template <class Merge>
void _divide_and_conquer (unsigned int lower,
unsigned int upper,
void _divide_and_conquer (unsigned int lower, unsigned int upper,
std::vector<Arr_entry>& arr_vec,
unsigned int k,
Merge merge_func)
unsigned int k, Merge merge_func)
{
if ((upper - lower) < k)
{
@ -977,16 +949,12 @@ void _divide_and_conquer (unsigned int lower,
}
unsigned int sub_size = ((upper - lower + 1) / k);
unsigned int i = 0;
unsigned int curr_lower = lower;
for (; i<k-1; ++i, curr_lower += sub_size )
{
_divide_and_conquer (curr_lower,
curr_lower + sub_size-1,
arr_vec,
k,
_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);
@ -1010,7 +978,6 @@ void _reset_faces(Arrangement_2* arr) const
}
}
void _insert(const Polygon_2& pgn, Arrangement_2& arr);
void _insert(const Polygon_with_holes_2& pgn, Arrangement_2& arr);
@ -1019,7 +986,8 @@ template< class PolygonIter >
void _insert(PolygonIter p_begin, PolygonIter p_end, Polygon_2& pgn);
template<class PolygonIter>
void _insert(PolygonIter p_begin, PolygonIter p_end, Polygon_with_holes_2& pgn);
void _insert(PolygonIter p_begin, PolygonIter p_end,
Polygon_with_holes_2& pgn);
template <class OutputIterator>
void _construct_curves(const Polygon_2& pgn, OutputIterator oi);
@ -1076,11 +1044,8 @@ void _intersection(const Polygon_& pgn)
{
if (_is_empty(pgn))
this->clear();
if(_is_plane(pgn))
return;
if(this->is_empty())
return;
if (_is_plane(pgn)) return;
if (this->is_empty()) return;
if (this->is_plane())
{
Arrangement_2* arr = new Arrangement_2(m_traits);
@ -1102,13 +1067,8 @@ void _intersection(const Polygon_& pgn)
m_arr->clear();
return;
}
if(other.is_plane())
return;
if(this->is_empty())
return;
if (other.is_plane()) return;
if (this->is_empty()) return;
if (this->is_plane())
{
*(this->m_arr) = *(other.m_arr);
@ -1129,8 +1089,7 @@ void _intersection(const Polygon_& pgn)
remove_redundant_edges();
}
void _join(const Arrangement_2& arr1,
const Arrangement_2& arr2,
void _join(const Arrangement_2& arr1, const Arrangement_2& arr2,
Arrangement_2& res)
{
Gps_join_functor<Arrangement_2> func;
@ -1142,8 +1101,7 @@ void _join(const Arrangement_2& arr1,
template <class Polygon_>
void _join(const Polygon_& pgn)
{
if(_is_empty(pgn))
return;
if (_is_empty(pgn)) return;
if (_is_plane(pgn))
{
this->clear();
@ -1158,9 +1116,7 @@ void _join(const Polygon_& pgn)
this->m_arr = arr;
return;
}
if(this->is_plane())
return;
if (this->is_plane()) return;
Arrangement_2 second_arr;
_insert(pgn, second_arr);
@ -1170,8 +1126,7 @@ void _join(const Polygon_& pgn)
void _join(const Self& other)
{
if(other.is_empty())
return;
if (other.is_empty()) return;
if (other.is_plane())
{
this->clear();
@ -1183,9 +1138,7 @@ void _join(const Self& other)
*(this->m_arr) = *(other.m_arr);
return;
}
if(this->is_plane())
return;
if (this->is_plane()) return;
_join(*(other.m_arr));
}
@ -1201,8 +1154,7 @@ void _difference(const Arrangement_2& arr)
fix_curves_direction();
}
void _difference(const Arrangement_2& arr1,
const Arrangement_2& arr2,
void _difference(const Arrangement_2& arr1, const Arrangement_2& arr2,
Arrangement_2& res)
{
Gps_difference_functor<Arrangement_2> func;
@ -1215,17 +1167,13 @@ void _difference(const Arrangement_2& arr1,
template <class Polygon_>
void _difference(const Polygon_& pgn)
{
if(_is_empty(pgn))
return;
if (_is_empty(pgn)) return;
if (_is_plane(pgn))
{
this->clear();
return;
}
if(this->is_empty())
return;
if (this->is_empty()) return;
if (this->is_plane())
{
Arrangement_2* arr = new Arrangement_2(m_traits);
@ -1244,17 +1192,13 @@ void _difference(const Polygon_& pgn)
void _difference(const Self& other)
{
if(other.is_empty())
return;
if (other.is_empty()) return;
if (other.is_plane())
{
this->clear();
return;
}
if(this->is_empty())
{
return;
}
if (this->is_empty()) return;
if (this->is_plane())
{
*(this->m_arr) = *(other.m_arr);
@ -1290,8 +1234,7 @@ void _symmetric_difference(const Arrangement_2& arr1,
template <class Polygon_>
void _symmetric_difference(const Polygon_& pgn)
{
if(_is_empty(pgn))
return;
if (_is_empty(pgn)) return;
if (_is_plane(pgn))
{
@ -1325,8 +1268,7 @@ void _symmetric_difference(const Polygon_& pgn)
void _symmetric_difference(const Self& other)
{
if(other.is_empty())
return;
if (other.is_empty()) return;
if (other.is_plane())
{

View File

@ -16,6 +16,7 @@
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_POLYGON_SET_2_H
#define CGAL_POLYGON_SET_2_H
@ -23,19 +24,22 @@
#include <CGAL/Polygon_2.h>
#include <CGAL/General_polygon_set_2.h>
#include <CGAL/Gps_segment_traits_2.h>
#include <CGAL/Boolean_set_operations_2/Gps_dcel.h>
#include <vector>
CGAL_BEGIN_NAMESPACE
template <class Kernel,
class Containter = std::vector<typename Kernel::Point_2> >
typename Containter = std::vector<typename Kernel::Point_2>,
class Dcel_ = Gps_dcel<Gps_segment_traits_2<Kernel, Containter> > >
class Polygon_set_2 :
public General_polygon_set_2<Gps_segment_traits_2<Kernel, Containter> >
public General_polygon_set_2<Gps_segment_traits_2<Kernel, Containter>, Dcel_>
{
private:
typedef General_polygon_set_2<Gps_segment_traits_2<Kernel, Containter> >
typedef General_polygon_set_2<Gps_segment_traits_2<Kernel, Containter>, Dcel_>
Base;
typedef Polygon_set_2<Kernel, Containter> Self;
typedef Polygon_set_2<Kernel, Containter, Dcel_> Self;
public:
typedef typename Base::Traits_2 Traits_2;
@ -97,10 +101,8 @@ public:
}
template <class InputIterator1, class InputIterator2>
inline void intersection(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2)
inline void intersection(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2)
{
Base::intersection(begin1, end1, begin2, end2);
}
@ -132,10 +134,8 @@ public:
}
template <class InputIterator1, class InputIterator2>
inline void join(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2)
inline void join(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2)
{
Base::join(begin1, end1, begin2, end2);
}
@ -167,10 +167,8 @@ public:
}
template <class InputIterator1, class InputIterator2>
inline void difference(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2)
inline void difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2)
{
Base::difference(begin1, end1, begin2, end2);
}
@ -202,10 +200,8 @@ public:
}
template <class InputIterator1, class InputIterator2>
inline void symmetric_difference(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2)
inline void symmetric_difference(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2)
{
Base::symmetric_difference(begin1, end1, begin2, end2);
}
@ -232,10 +228,8 @@ public:
}
template <class InputIterator1, class InputIterator2>
inline bool do_intersect(InputIterator1 begin1,
InputIterator1 end1,
InputIterator2 begin2,
InputIterator2 end2)
inline bool do_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2)
{
return (Base::do_intersect(begin1, end1, begin2, end2));
}