mirror of https://github.com/CGAL/cgal
really finish traits copy-constructor bug fix
This commit is contained in:
parent
93011c08b4
commit
33d5de45ad
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
#include <CGAL/Arrangement_on_surface_2.h>
|
||||
#include <CGAL/Arr_accessor.h>
|
||||
|
|
@ -195,151 +196,109 @@ void insert(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
|||
insert (arr, c, def_pl);
|
||||
}
|
||||
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* This generic functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is not the same as the type GeomTraits.
|
||||
* In this case, we instantiate a local variable of the former and provide
|
||||
* the later as a single parameter to the constructor
|
||||
*/
|
||||
template <bool b>
|
||||
struct Arr_empty_inserter {
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits, typename InputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
void insert_empty(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
InputIterator begin_xcurves, InputIterator end_xcurves)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_construction_visitor
|
||||
Construct_visitor;
|
||||
typedef typename Construct_visitor::Traits_2 Construct_traits;
|
||||
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
Construct_visitor visitor(&arr);
|
||||
typename Construct_visitor::Traits_2 traits(*geom_traits);
|
||||
|
||||
/* If the type Construct_visitor::Traits_2 is the same as the type GeomTraits,
|
||||
* use a reference to GeomTraits to avoid constructing a new one.
|
||||
* Otherwise, instantiate a local variable of the former and provide
|
||||
* the later as a single parameter to the constructor
|
||||
*/
|
||||
typename boost::mpl::if_<boost::is_same<GeomTraits, Construct_traits>,
|
||||
Construct_traits&, Construct_traits>::type
|
||||
traits = *geom_traits;
|
||||
|
||||
// Define a sweep-line instance and perform the sweep:
|
||||
Sweep_line_2<typename Construct_visitor::Traits_2,
|
||||
Construct_visitor,
|
||||
Sweep_line_2<typename Construct_visitor::Traits_2, Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves);
|
||||
}
|
||||
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
/*! Insert a range of x-monotone curves and a range of isolated points into
|
||||
* an empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
* \param begin_xcurves the begining of the curve range
|
||||
* \param end_xcurves past-the-end curve range
|
||||
* \param begin_points the begining of the point range
|
||||
* \param end_points past-the-end point range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
void insert_empty(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_construction_visitor
|
||||
Construct_visitor;
|
||||
typedef typename Construct_visitor::Traits_2 Construct_traits;
|
||||
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
Construct_visitor visitor(&arr);
|
||||
typename Construct_visitor::Traits_2 traits(*geom_traits);
|
||||
|
||||
/* If the type Construct_visitor::Traits_2 is the same as the type GeomTraits,
|
||||
* use a reference to GeomTraits to avoid constructing a new one.
|
||||
* Otherwise, instantiate a local variable of the former and provide
|
||||
* the later as a single parameter to the constructor
|
||||
*/
|
||||
typename boost::mpl::if_<boost::is_same<GeomTraits, Construct_traits>,
|
||||
Construct_traits&, Construct_traits>::type
|
||||
traits = *geom_traits;
|
||||
|
||||
// Define a sweep-line instance and perform the sweep.
|
||||
Sweep_line_2<typename Construct_visitor::Traits_2,
|
||||
Construct_visitor,
|
||||
Sweep_line_2<typename Construct_visitor::Traits_2, Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves, begin_points, end_points);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* This specialized functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is the same as the type GeomTraits.
|
||||
* In this case, we simply assign the former to a reference of the later
|
||||
* to avoid an erroneous call to a copy constructor.
|
||||
*/
|
||||
template <>
|
||||
struct Arr_empty_inserter<true> {
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits, typename InputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
InputIterator begin_xcurves, InputIterator end_xcurves)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_construction_visitor
|
||||
Construct_visitor;
|
||||
Construct_visitor visitor(&arr);
|
||||
typename Construct_visitor::Traits_2 & traits = *geom_traits;
|
||||
|
||||
// Define a sweep-line instance and perform the sweep:
|
||||
Sweep_line_2<typename Construct_visitor::Traits_2,
|
||||
Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves);
|
||||
}
|
||||
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
void insert_non_empty(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves,
|
||||
XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_construction_visitor
|
||||
Construct_visitor;
|
||||
Construct_visitor visitor(&arr);
|
||||
typename Construct_visitor::Traits_2 & traits = *geom_traits;
|
||||
// Define a sweep-line instance and perform the sweep.
|
||||
Sweep_line_2<typename Construct_visitor::Traits_2,
|
||||
Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves, end_points, end_points);
|
||||
}
|
||||
};
|
||||
typedef typename TopTraits::Sweep_line_insertion_visitor
|
||||
Insert_visitor;
|
||||
typedef typename Insert_visitor::Traits_2 Insert_traits;
|
||||
typedef typename Insert_visitor::Traits_2::X_monotone_curve_2
|
||||
Ex_x_monotone_curve_2;
|
||||
typedef typename Insert_visitor::Traits_2::Point_2 Ex_point_2;
|
||||
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* This generic functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is not the same as the type GeomTraits.
|
||||
* In this case, we instantiate a local variable of the former and provide
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
Insert_visitor visitor(&arr);
|
||||
|
||||
/* If the type Insert_visitor::Traits_2 is the same as the type GeomTraits,
|
||||
* use a reference to GeomTraits to avoid constructing a new one.
|
||||
* Otherwise, instantiate a local variable of the former and provide
|
||||
* the later as a single parameter to the constructor
|
||||
*/
|
||||
template <bool b>
|
||||
struct Arr_non_empty_inserter {
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_insertion_visitor
|
||||
Insert_visitor;
|
||||
Insert_visitor visitor(&arr);
|
||||
typename Insert_visitor::Traits_2 traits(*geom_traits);
|
||||
typename boost::mpl::if_<boost::is_same<GeomTraits, Insert_traits>,
|
||||
Insert_traits&, Insert_traits>::type
|
||||
traits = *geom_traits;
|
||||
|
||||
// Create a set of existing as well as new curves and points.
|
||||
typedef typename Insert_visitor::Traits_2::X_monotone_curve_2
|
||||
Ex_x_monotone_curve_2;
|
||||
typedef typename Insert_visitor::Traits_2::Point_2 Ex_point_2;
|
||||
std::list<Ex_x_monotone_curve_2> ex_cvs;
|
||||
std::list<Ex_point_2> ex_pts;
|
||||
|
||||
|
|
@ -355,58 +314,7 @@ struct Arr_non_empty_inserter {
|
|||
typename Insert_visitor::Subcurve,
|
||||
typename Insert_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep (ex_cvs.begin(), ex_cvs.end(),
|
||||
ex_pts.begin(), ex_pts.end());
|
||||
}
|
||||
};
|
||||
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* This specialized functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is the same as the type GeomTraits.
|
||||
* In this case, we simply assign the former to a reference of the later
|
||||
* to avoid an erroneous call to a copy constructor.
|
||||
*/
|
||||
template <>
|
||||
struct Arr_non_empty_inserter<true> {
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_insertion_visitor
|
||||
Insert_visitor;
|
||||
Insert_visitor visitor(&arr);
|
||||
typename Insert_visitor::Traits_2 & traits = geom_traits;
|
||||
|
||||
// Create a set of existing as well as new curves and points.
|
||||
typedef typename Insert_visitor::Traits_2::X_monotone_curve_2
|
||||
Ex_x_monotone_curve_2;
|
||||
typedef typename Insert_visitor::Traits_2::Point_2 Ex_point_2;
|
||||
std::list<Ex_x_monotone_curve_2> ex_cvs;
|
||||
std::list<Ex_point_2> ex_pts;
|
||||
|
||||
prepare_for_sweep(arr,
|
||||
begin_xcurves, end_xcurves, // the x-monotone curves
|
||||
begin_points, end_points, // the points (if any)
|
||||
std::back_inserter(ex_cvs),
|
||||
std::back_inserter(ex_pts),
|
||||
&traits);
|
||||
|
||||
// Define a basic sweep-line instance and perform the sweep.
|
||||
Sweep_line_2<typename Insert_visitor::Traits_2, Insert_visitor,
|
||||
typename Insert_visitor::Subcurve,
|
||||
typename Insert_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep (ex_cvs.begin(), ex_cvs.end(),
|
||||
ex_pts.begin(), ex_pts.end());
|
||||
}
|
||||
sweep_line.sweep(ex_cvs.begin(), ex_cvs.end(),ex_pts.begin(), ex_pts.end());
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -449,24 +357,12 @@ void insert (Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
|||
std::back_inserter(xcurves), std::back_inserter(iso_points),
|
||||
geom_traits);
|
||||
|
||||
if (arr.is_empty()) {
|
||||
// The arrangement is empty: use the construction visitor.
|
||||
typedef typename TopTraits::Sweep_line_construction_visitor
|
||||
Construct_visitor;
|
||||
typedef typename Construct_visitor::Traits_2 Visitor_traits;
|
||||
Arr_empty_inserter<boost::is_same<GeomTraits, Visitor_traits>::value>
|
||||
insert_empty;
|
||||
if (arr.is_empty())
|
||||
insert_empty(arr, xcurves.begin(), xcurves.end(),
|
||||
iso_points.begin(), iso_points.end());
|
||||
} else {
|
||||
// The arrangement is not empty: use the insertion visitor.
|
||||
typedef typename TopTraits::Sweep_line_insertion_visitor Insert_visitor;
|
||||
typedef typename Insert_visitor::Traits_2 Visitor_traits;
|
||||
Arr_non_empty_inserter<boost::is_same<GeomTraits, Visitor_traits>::value>
|
||||
insert_non_empty;
|
||||
else
|
||||
insert_non_empty(arr, xcurves.begin(), xcurves.end(),
|
||||
iso_points.begin(), iso_points.end());
|
||||
}
|
||||
|
||||
// Notify the arrangement observers that the global operation has been
|
||||
// completed.
|
||||
|
|
@ -504,23 +400,11 @@ void insert(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
|||
// Choose the operation depending on whether the input arrangement is
|
||||
// empty (then we construct it from scratch), or not (where we just insert
|
||||
// the new curves).
|
||||
if (arr.is_empty()) {
|
||||
// The arrangement is empty: use the construction visitor.
|
||||
typedef typename TopTraits::Sweep_line_construction_visitor
|
||||
Construct_visitor;
|
||||
typedef typename Construct_visitor::Traits_2 Visitor_traits;
|
||||
Arr_empty_inserter<boost::is_same<GeomTraits, Visitor_traits>::value>
|
||||
insert_empty;
|
||||
if (arr.is_empty())
|
||||
insert_empty(arr, begin, end);
|
||||
}
|
||||
else {
|
||||
// The arrangement is not empty: use the insertion visitor.
|
||||
typedef typename TopTraits::Sweep_line_insertion_visitor Insert_visitor;
|
||||
typedef typename Insert_visitor::Traits_2 Visitor_traits;
|
||||
typedef typename GeomTraits::Point_2 Point_2;
|
||||
Arr_non_empty_inserter<boost::is_same<GeomTraits, Visitor_traits>::value>
|
||||
insert_non_empty;
|
||||
std::list<Point_2> empty;
|
||||
std::list<typename GeomTraits::Point_2> empty;
|
||||
insert_non_empty(arr, begin, end, empty.begin(), empty.end());
|
||||
}
|
||||
|
||||
|
|
@ -802,22 +686,16 @@ insert_non_intersecting_curve
|
|||
return (insert_non_intersecting_curve (arr, c, def_pl));
|
||||
}
|
||||
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* This generic functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is not the same as the type GeomTraits.
|
||||
* In this case, we instantiate a local variable of the former and provide
|
||||
* the later as a single parameter to the constructor
|
||||
*/
|
||||
template <bool b>
|
||||
struct Arr_empty_basic_inserter {
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits, typename InputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
InputIterator begin_xcurves, InputIterator end_xcurves)
|
||||
void non_intersecting_insert_empty(Arrangement_on_surface_2<GeomTraits,
|
||||
TopTraits>& arr,
|
||||
InputIterator begin_xcurves,
|
||||
InputIterator end_xcurves)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_construction_visitor
|
||||
|
|
@ -841,95 +719,38 @@ struct Arr_empty_basic_inserter {
|
|||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
void non_intersecting_insert_empty(Arrangement_on_surface_2<GeomTraits,
|
||||
TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves,
|
||||
XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points,
|
||||
PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_construction_visitor
|
||||
Construct_visitor;
|
||||
Construct_visitor visitor(&arr);
|
||||
typename Construct_visitor::Traits_2 traits(*geom_traits);
|
||||
// Define a basic sweep-line instance (which is not supposed to handle
|
||||
// insersections) and perform the sweep.
|
||||
Basic_sweep_line_2<typename Construct_visitor::Traits_2,
|
||||
Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves, begin_points, end_points);
|
||||
}
|
||||
};
|
||||
typedef typename Construct_visitor::Traits_2 Construct_traits;
|
||||
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* This specialized functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is the same as the type GeomTraits.
|
||||
* In this case, we simply assign the former to a reference of the later
|
||||
* to avoid an erroneous call to a copy constructor.
|
||||
*/
|
||||
template <>
|
||||
struct Arr_empty_basic_inserter<true> {
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits, typename InputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
InputIterator begin_xcurves, InputIterator end_xcurves)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_construction_visitor
|
||||
Construct_visitor;
|
||||
Construct_visitor visitor(&arr);
|
||||
typename Construct_visitor::Traits_2 & traits = *geom_traits;
|
||||
|
||||
// Define a basic sweep-line instance (which is not supposed to handle
|
||||
// insersections) and perform the sweep.
|
||||
Basic_sweep_line_2<typename Construct_visitor::Traits_2,
|
||||
Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves);
|
||||
}
|
||||
|
||||
/*! Insert a range of x-monotone curves into an empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_construction_visitor
|
||||
Construct_visitor;
|
||||
Construct_visitor visitor(&arr);
|
||||
typename Construct_visitor::Traits_2 & traits = *geom_traits;
|
||||
|
||||
// Define a basic sweep-line instance (which is not supposed to handle
|
||||
// insersections) and perform the sweep.
|
||||
Basic_sweep_line_2<typename Construct_visitor::Traits_2,
|
||||
Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves, begin_points, end_points);
|
||||
}
|
||||
};
|
||||
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* This generic functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is not the same as the type GeomTraits.
|
||||
* In this case, we instantiate a local variable of the former and provide
|
||||
/* If the type Construct_visitor::Traits_2 is the same as the type GeomTraits,
|
||||
* use a reference to GeomTraits to avoid constructing a new one.
|
||||
* Otherwise, instantiate a local variable of the former and provide
|
||||
* the later as a single parameter to the constructor
|
||||
*/
|
||||
template <bool b>
|
||||
struct Arr_non_empty_basic_inserter {
|
||||
typename boost::mpl::if_<boost::is_same<GeomTraits, Construct_traits>,
|
||||
Construct_traits&, Construct_traits>::type
|
||||
traits = *geom_traits;
|
||||
|
||||
// Define a basic sweep-line instance (which is not supposed to handle
|
||||
// insersections) and perform the sweep.
|
||||
Basic_sweep_line_2<typename Construct_visitor::Traits_2, Construct_visitor,
|
||||
typename Construct_visitor::Subcurve,
|
||||
typename Construct_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(begin_xcurves, end_xcurves, begin_points, end_points);
|
||||
}
|
||||
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
|
|
@ -937,20 +758,33 @@ struct Arr_non_empty_basic_inserter {
|
|||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
void non_intersecting_insert_non_empty(Arrangement_on_surface_2<GeomTraits,
|
||||
TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves,
|
||||
XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points,
|
||||
PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_insertion_visitor
|
||||
Insert_visitor;
|
||||
Insert_visitor visitor(&arr);
|
||||
typename Insert_visitor::Traits_2 traits(*geom_traits);
|
||||
|
||||
// Create a set of existing as well as new curves and points.
|
||||
typedef typename Insert_visitor::Traits_2 Insert_traits;
|
||||
typedef typename Insert_visitor::Traits_2::X_monotone_curve_2
|
||||
Ex_x_monotone_curve_2;
|
||||
typedef typename Insert_visitor::Traits_2::Point_2 Ex_point_2;
|
||||
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
Insert_visitor visitor(&arr);
|
||||
|
||||
/* If the type Construct_visitor::Traits_2 is the same as the type GeomTraits,
|
||||
* use a reference to GeomTraits to avoid constructing a new one.
|
||||
* Otherwise, instantiate a local variable of the former and provide
|
||||
* the later as a single parameter to the constructor
|
||||
*/
|
||||
typename boost::mpl::if_<boost::is_same<GeomTraits, Insert_traits>,
|
||||
Insert_traits&, Insert_traits>::type
|
||||
traits = *geom_traits;
|
||||
|
||||
// Create a set of existing as well as new curves and points.
|
||||
std::list<Ex_x_monotone_curve_2> ex_cvs;
|
||||
std::list<Ex_point_2> ex_pts;
|
||||
|
||||
|
|
@ -966,59 +800,8 @@ struct Arr_non_empty_basic_inserter {
|
|||
typename Insert_visitor::Subcurve,
|
||||
typename Insert_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep (ex_cvs.begin(), ex_cvs.end(),
|
||||
ex_pts.begin(), ex_pts.end());
|
||||
sweep_line.sweep(ex_cvs.begin(), ex_cvs.end(), ex_pts.begin(), ex_pts.end());
|
||||
}
|
||||
};
|
||||
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* This specialized functor is instantiated when the type
|
||||
* Construct_visitor::Traits_2 is the same as the type GeomTraits.
|
||||
* In this case, we simply assign the former to a reference of the later
|
||||
* to avoid an erroneous call to a copy constructor.
|
||||
*/
|
||||
template <>
|
||||
struct Arr_non_empty_basic_inserter<true> {
|
||||
/*! Insert a range of x-monotone curves into a non-empty arrangement
|
||||
* \param arr the resulting arrangement
|
||||
* \param begin the begining of the curve range
|
||||
* \param end past-the-end curve range
|
||||
*/
|
||||
template <typename GeomTraits, typename TopTraits,
|
||||
typename XcInputIterator, typename PInputIterator>
|
||||
void operator()(Arrangement_on_surface_2<GeomTraits, TopTraits>& arr,
|
||||
XcInputIterator begin_xcurves, XcInputIterator end_xcurves,
|
||||
PInputIterator begin_points, PInputIterator end_points)
|
||||
{
|
||||
GeomTraits * geom_traits = arr.geometry_traits();
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_insertion_visitor
|
||||
Insert_visitor;
|
||||
Insert_visitor visitor(&arr);
|
||||
typename Insert_visitor::Traits_2 & traits = geom_traits;
|
||||
|
||||
// Create a set of existing as well as new curves and points.
|
||||
typedef typename Insert_visitor::Traits_2::X_monotone_curve_2
|
||||
Ex_x_monotone_curve_2;
|
||||
typedef typename Insert_visitor::Traits_2::Point_2 Ex_point_2;
|
||||
std::list<Ex_x_monotone_curve_2> ex_cvs;
|
||||
std::list<Ex_point_2> ex_pts;
|
||||
|
||||
prepare_for_sweep(arr,
|
||||
begin_xcurves, end_xcurves, // The x-monotone curves
|
||||
begin_points, end_points, // The points (if any)
|
||||
std::back_inserter(ex_cvs),
|
||||
std::back_inserter(ex_pts),
|
||||
&traits);
|
||||
|
||||
// Define a basic sweep-line instance and perform the sweep.
|
||||
Basic_sweep_line_2<typename Insert_visitor::Traits_2, Insert_visitor,
|
||||
typename Insert_visitor::Subcurve,
|
||||
typename Insert_visitor::Event>
|
||||
sweep_line(&traits, &visitor);
|
||||
sweep_line.sweep(ex_cvs.begin(), ex_cvs.end(),
|
||||
ex_pts.begin(), ex_pts.end());
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Insert a range of pairwise interior-disjoint x-monotone curves into
|
||||
|
|
@ -1042,24 +825,12 @@ void insert_non_intersecting_curves
|
|||
// Choose the operation depending on whether the input arrangement is
|
||||
// empty (then we construct it from scratch), or not (where we just insert
|
||||
// the new curves).
|
||||
if (arr.is_empty()) {
|
||||
// The arrangement is empty: use the construction visitor.
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_construction_visitor
|
||||
Construct_visitor;
|
||||
typedef typename Construct_visitor::Traits_2 Visitor_traits;
|
||||
Arr_empty_basic_inserter<boost::is_same<GeomTraits,Visitor_traits>::value>
|
||||
insert_empty;
|
||||
insert_empty(arr, begin, end);
|
||||
} else {
|
||||
// The arrangement is not empty: use the insertion visitor.
|
||||
typedef typename TopTraits::Sweep_line_non_intersecting_insertion_visitor
|
||||
Insert_visitor;
|
||||
typedef typename Insert_visitor::Traits_2 Visitor_traits;
|
||||
typedef typename GeomTraits::Point_2 Point_2;
|
||||
Arr_non_empty_basic_inserter<boost::is_same<GeomTraits,Visitor_traits>::
|
||||
value> insert_non_empty;
|
||||
std::list<Point_2> empty;
|
||||
insert_non_empty(arr, begin, end, empty.begin(), empty.end());
|
||||
if (arr.is_empty())
|
||||
non_intersecting_insert_empty(arr, begin, end);
|
||||
else {
|
||||
std::list<typename GeomTraits::Point_2> empty;
|
||||
non_intersecting_insert_non_empty(arr, begin, end,
|
||||
empty.begin(), empty.end());
|
||||
}
|
||||
|
||||
// Notify the arrangement observers that the global operation has been
|
||||
|
|
|
|||
Loading…
Reference in New Issue