remove Object from Minkowski_sum_2

This commit is contained in:
Sébastien Loriot 2023-06-20 19:11:00 +02:00
parent 76f16d7c38
commit fb2f2c6642
3 changed files with 61 additions and 74 deletions

View File

@ -584,9 +584,6 @@ public:
template <typename OutputIterator>
OutputIterator operator()(const Curve_2& cv, OutputIterator oi) const
{
typedef std::variant<Point_2, X_monotone_curve_2>
Make_x_monotone_result;
// Increment the serial number of the curve cv, which will serve as its
// unique identifier.
unsigned int index = 0;
@ -594,10 +591,10 @@ public:
if (cv.orientation() == COLLINEAR) {
// The curve is a line segment.
*oi++ = Make_x_monotone_result(X_monotone_curve_2(cv.supporting_line(),
*oi++ = X_monotone_curve_2(cv.supporting_line(),
cv.source(),
cv.target(),
index));
index);
return oi;
}
@ -608,8 +605,8 @@ public:
if (sign_rad == ZERO) {
// Create an isolated point.
*oi++ = Make_x_monotone_result(Point_2(circ.center().x(),
circ.center().y()));
*oi++ = Point_2(circ.center().x(),
circ.center().y());
return oi;
}
@ -622,59 +619,59 @@ public:
CGAL_assertion (n_vpts == 2);
// Subdivide the circle into two arcs (an upper and a lower half).
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
vpts[0], vpts[1],
cv.orientation(),
index));
index);
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
vpts[1], vpts[0],
cv.orientation(),
index));
index);
}
else {
// Act according to the number of vertical tangency points.
if (n_vpts == 2) {
// Subdivide the circular arc into three x-monotone arcs.
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
cv.source(), vpts[0],
cv.orientation(),
index));
index);
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
vpts[0], vpts[1],
cv.orientation(),
index));
index);
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
vpts[1],
cv.target(),
cv.orientation(),
index));
index);
}
else if (n_vpts == 1) {
// Subdivide the circular arc into two x-monotone arcs.
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
cv.source(),
vpts[0],
cv.orientation(),
index));
index);
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
vpts[0],
cv.target(),
cv.orientation(),
index));
index);
}
else {
CGAL_assertion(n_vpts == 0);
// The arc is already x-monotone:
*oi++ = Make_x_monotone_result(X_monotone_curve_2(circ,
*oi++ = X_monotone_curve_2(circ,
cv.source(),
cv.target(),
cv.orientation(),
index));
index);
}
}

View File

@ -168,12 +168,10 @@ protected:
typename Kernel::Orientation_2 f_orient = ker.orientation_2_object();
Traits_2 traits;
std::list<Object> xobjs;
std::list<Object>::iterator xobj_it;
std::list<std::variant<Tr_point_2, X_monotone_curve_2>> xobjs;
typename Traits_2::Make_x_monotone_2
f_make_x_monotone = traits.make_x_monotone_2_object();
Curve_2 arc;
X_monotone_curve_2 xarc;
do
{
@ -517,12 +515,11 @@ protected:
// convolution cycle.
xobjs.clear();
f_make_x_monotone (arc, std::back_inserter(xobjs));
for (xobj_it = xobjs.begin(); xobj_it != xobjs.end(); ++xobj_it) {
assign_success = CGAL::assign (xarc, *xobj_it);
CGAL_assertion (assign_success);
CGAL_USE(assign_success);
*oi++ = Labeled_curve_2 (xarc,
X_curve_label (xarc.is_directed_right(),
for (auto xobj_it = xobjs.begin(); xobj_it != xobjs.end(); ++xobj_it) {
const X_monotone_curve_2* xarc = std::get_if<X_monotone_curve_2>(&(*xobj_it));
CGAL_assertion(xarc!=nullptr);
*oi++ = Labeled_curve_2 (*xarc,
X_curve_label (xarc->is_directed_right(),
cycle_id, curve_index++));
}
}
@ -571,18 +568,17 @@ protected:
xobjs.clear();
f_make_x_monotone (arc, std::back_inserter(xobjs));
xobj_it = xobjs.begin();
auto xobj_it = xobjs.begin();
while (xobj_it != xobjs.end())
{
assign_success = CGAL::assign (xarc, *xobj_it);
CGAL_assertion (assign_success);
CGAL_USE(assign_success);
const X_monotone_curve_2* xarc = std::get_if<X_monotone_curve_2>(&(*xobj_it));
CGAL_assertion (xarc != nullptr);
++xobj_it;
bool is_last = (xobj_it == xobjs.end());
*oi++ = Labeled_curve_2 (xarc,
X_curve_label (xarc.is_directed_right(),
*oi++ = Labeled_curve_2 (*xarc,
X_curve_label (xarc->is_directed_right(),
cycle_id, curve_index++, is_last));
}

View File

@ -117,7 +117,7 @@ protected:
Algebraic a, b, c;
unsigned int curve_index(0);
std::list<Object> xobjs;
std::list<std::variant<typename Traits_2::Point_2,X_monotone_curve_2>> xobjs;
Traits_2 traits;
auto nt_traits = traits.nt_traits();
@ -127,8 +127,6 @@ protected:
auto alg_ker = traits.alg_kernel();
auto f_equal = alg_ker->equal_2_object();
bool assign_success;
do {
// Get a circulator for the next vertex (in the proper orientation).
if (forward) ++next;
@ -185,12 +183,10 @@ protected:
f_make_x_monotone(arc, std::back_inserter(xobjs));
for (auto xobj_it = xobjs.begin(); xobj_it != xobjs.end(); ++xobj_it) {
X_monotone_curve_2 xarc;
assign_success = CGAL::assign(xarc, *xobj_it);
CGAL_assertion (assign_success);
CGAL_USE(assign_success);
const X_monotone_curve_2* xarc = std::get_if<X_monotone_curve_2>(&(*xobj_it));
CGAL_assertion (xarc!=nullptr);
*oi++ = Labeled_curve_2(xarc, X_curve_label(xarc.is_directed_right(),
*oi++ = Labeled_curve_2(*xarc, X_curve_label(xarc->is_directed_right(),
cycle_id, curve_index));
curve_index++;
}
@ -237,15 +233,13 @@ protected:
auto xobj_it = xobjs.begin();
while (xobj_it != xobjs.end()) {
X_monotone_curve_2 xarc;
assign_success = CGAL::assign(xarc, *xobj_it);
CGAL_assertion (assign_success);
CGAL_USE(assign_success);
const X_monotone_curve_2* xarc = std::get_if<X_monotone_curve_2>(&(*xobj_it));
CGAL_assertion (xarc!=nullptr);
++xobj_it;
is_last = (xobj_it == xobjs.end());
*oi++ = Labeled_curve_2(xarc, X_curve_label(xarc.is_directed_right(),
*oi++ = Labeled_curve_2(*xarc, X_curve_label(xarc->is_directed_right(),
cycle_id, curve_index,
is_last));
curve_index++;