fix argt demo

changes in Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h
should be undo
This commit is contained in:
Sébastien Loriot 2023-08-04 16:56:55 +02:00
parent f06d9fb606
commit 89fd91e354
4 changed files with 48 additions and 32 deletions

View File

@ -961,15 +961,16 @@ findOtherInterestingPoints<demo_types::DemoTypes::Alg_seg_arr>
const CGAL::Bbox_2& allowable_range) {
using Traits = demo_types::DemoTypes::Alg_seg_traits;
CGAL::Bbox_2 bb = {};
std::vector<CGAL::Object> intersections;
typedef std::pair<typename Traits::Point_2, unsigned int> Pt_m;
std::vector<Pt_m> intersections;
for (auto it = arr->edges_begin(); it != arr->edges_end(); ++it) {
for (auto& arc : getXyCurves(arr->traits()))
{
if (arc.is_vertical() != it->curve().is_vertical())
it->curve().intersections(arc, std::back_inserter(intersections));
it->curve().intersections(arc, CGAL::dispatch_or_drop_output<Pt_m>(std::back_inserter(intersections)));
}
}
for (auto it = intersections.begin(); it != intersections.end(); it++) {
std::pair<typename Traits::Point_2, unsigned int> point_multiplicity;
CGAL::assign(point_multiplicity, *it);
for (auto point_multiplicity :intersections) {
auto& point = point_multiplicity.first;
if (point.location() == CGAL::ARR_INTERIOR) {
auto xy = point.to_double();

View File

@ -11,6 +11,8 @@
#include "IntersectCurves.h"
#include "ArrangementTypes.h"
#include <boost/function_output_iterator.hpp>
template <typename Traits_>
Intersect_curves<Traits_>::Intersect_curves(const Traits* traits) :
@ -18,12 +20,26 @@ Intersect_curves<Traits_>::Intersect_curves(const Traits* traits) :
{
}
struct Object_putter
{
std::vector<CGAL::Object>& v;
Object_putter(std::vector<CGAL::Object>& v)
: v(v)
{}
template <class T>
void operator()(const T& t)
{
v.push_back(make_object(t));
}
};
template <typename Traits_>
void Intersect_curves<Traits_>::operator()(
const X_monotone_curve_2& cv1, const X_monotone_curve_2& cv2,
std::vector<CGAL::Object>& output)
{
this->intersect(cv1, cv2, std::back_inserter(output));
this->intersect(cv1, cv2, boost::make_function_output_iterator(Object_putter(output)));
}
ARRANGEMENT_DEMO_SPECIALIZE_TRAITS(Intersect_curves)

View File

@ -625,14 +625,14 @@ operator()(const X_monotone_curve_2& curve, const CoordinateType& x,
Point_2 p2c1(x, CoordinateType(clipRect.ymax() + 1));
const X_monotone_curve_2 verticalLine = ctr_xcv(p1c1, p2c1);
CGAL::Object o;
CGAL::Oneset_iterator<CGAL::Object> oi(o);
std::vector<IntersectionResult> pairs;
this->intersectCurves(curve, verticalLine, oi);
this->intersectCurves(curve, verticalLine,
CGAL::dispatch_or_drop_output<IntersectionResult>(std::back_inserter(pairs)));
IntersectionResult pair;
if (CGAL::assign(pair, o)) {
Point_2 pt = pair.first;
if (!pairs.empty()) {
Point_2 pt = pairs[0].first;
res = pt.y();
}
return res;
@ -654,14 +654,13 @@ operator()(const X_monotone_curve_2& curve, const CoordinateType& x,
Point_2 p2c1(x, CoordinateType(10000000)); // upper bounding box
const X_monotone_curve_2 verticalLine = ctr_xcv(p1c1, p2c1);
CGAL::Object o;
CGAL::Oneset_iterator<CGAL::Object> oi(o);
std::vector<IntersectionResult> pairs;
this->intersectCurves(curve, verticalLine, oi);
this->intersectCurves(curve, verticalLine,
CGAL::dispatch_or_drop_output<IntersectionResult>(std::back_inserter(pairs)));
IntersectionResult pair;
if (CGAL::assign(pair, o)) {
Point_2 pt = pair.first;
if (!pairs.empty()) {
Point_2 pt = pairs[0].first;
res = pt.y();
}
return res;
@ -681,15 +680,15 @@ operator()(const X_monotone_curve_2& curve, const Coordinate_type& x)
Point_2 p2c1(x, Coordinate_type(clip_rect.ymax() + 1));
const X_monotone_curve_2 vertical_line = ctr_xcv(p1c1, p2c1);
CGAL::Object o;
CGAL::Oneset_iterator<CGAL::Object> oi(o);
this->intersect_curves(curve, vertical_line, oi);
std::vector<IntersectionResult> pairs;
this->intersect_curves(curve, vertical_line,
CGAL::dispatch_or_drop_output<IntersectionResult>(std::back_inserter(pairs)));
Coordinate_type res(0);
IntersectionResult pair;
if (CGAL::assign(pair, o)) {
Point_2 pt = pair.first;
if (!pairs.empty()) {
Point_2 pt = pairs[0].first;
res = pt.y();
}
return res;
@ -708,15 +707,15 @@ auto Arr_compute_y_at_x_2<CGAL::Arr_algebraic_segment_traits_2<Coefficient_>>::
operator()(const X_monotone_curve_2& curve, const CoordinateType& x)
-> CoordinateType
{
CGAL::Object o;
CGAL::Oneset_iterator<CGAL::Object> oi(o);
Intersect_2 intersect = traits->intersect_2_object();
X_monotone_curve_2 c2 = this->makeVerticalLine(x);
intersect(curve, c2, oi);
std::pair<Point_2, Multiplicity> res;
if (CGAL::assign(res, o)) {
typedef std::pair<Point_2, Multiplicity> PtM;
std::vector<PtM> res;
intersect(curve, c2, CGAL::dispatch_or_drop_output<PtM>(std::back_inserter(res)));
if (!res.empty()) {
// TODO: handle failure case
const Point_2& p = res.first;
const Point_2& p = res[0].first;
CoordinateType coord = p.y();
return coord;
}

View File

@ -826,7 +826,7 @@ public:
std::get_if<X_monotone_subcurve_2>(&xection);
if (subcv_p != nullptr) {
ocv.push_back(*subcv_p);
oi = output_ocv (ocv, invert_ocv, oi);
output_ocv (ocv, invert_ocv, oi);
continue;
}
@ -883,7 +883,7 @@ public:
// An overlap occurred at the previous iteration:
// Output the overlapping polycurve.
CGAL_assertion(ocv.size() > 0);
oi = output_ocv (ocv, invert_ocv, oi);
output_ocv (ocv, invert_ocv, oi);
}
else {
// The left point of the current subcurve of one
@ -929,7 +929,7 @@ public:
// Output the remaining overlapping polycurve, if necessary.
if (ocv.size() > 0) {
oi = output_ocv (ocv, invert_ocv, oi);
output_ocv (ocv, invert_ocv, oi);
}
else if (right_coincides) {
typedef std::pair<Point_2,Multiplicity> return_point;