From 89fd91e35440048343c4df33c2e283ecb2f6e50a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 4 Aug 2023 16:56:55 +0200 Subject: [PATCH] fix argt demo changes in Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h should be undo --- .../ArrangementGraphicsItem.cpp | 11 ++--- .../Utils/IntersectCurves.cpp | 18 +++++++- .../Arrangement_on_surface_2/Utils/Utils.cpp | 45 +++++++++---------- .../include/CGAL/Arr_polycurve_traits_2.h | 6 +-- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementGraphicsItem.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementGraphicsItem.cpp index 86ad76fe086..d8573dfa0cb 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementGraphicsItem.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementGraphicsItem.cpp @@ -961,15 +961,16 @@ findOtherInterestingPoints const CGAL::Bbox_2& allowable_range) { using Traits = demo_types::DemoTypes::Alg_seg_traits; CGAL::Bbox_2 bb = {}; - std::vector intersections; + typedef std::pair Pt_m; + std::vector 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(std::back_inserter(intersections))); + } } - for (auto it = intersections.begin(); it != intersections.end(); it++) { - std::pair 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(); diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp index f2d154c4eac..ef0d027ab85 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp @@ -11,6 +11,8 @@ #include "IntersectCurves.h" #include "ArrangementTypes.h" +#include + template Intersect_curves::Intersect_curves(const Traits* traits) : @@ -18,12 +20,26 @@ Intersect_curves::Intersect_curves(const Traits* traits) : { } +struct Object_putter +{ + std::vector& v; + Object_putter(std::vector& v) + : v(v) + {} + + template + void operator()(const T& t) + { + v.push_back(make_object(t)); + } +}; + template void Intersect_curves::operator()( const X_monotone_curve_2& cv1, const X_monotone_curve_2& cv2, std::vector& 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) diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp index 438b8214908..df21f6699ab 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp @@ -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 oi(o); + std::vector pairs; - this->intersectCurves(curve, verticalLine, oi); + this->intersectCurves(curve, verticalLine, + CGAL::dispatch_or_drop_output(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 oi(o); + std::vector pairs; - this->intersectCurves(curve, verticalLine, oi); + this->intersectCurves(curve, verticalLine, + CGAL::dispatch_or_drop_output(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 oi(o); - this->intersect_curves(curve, vertical_line, oi); + std::vector pairs; + + this->intersect_curves(curve, vertical_line, + CGAL::dispatch_or_drop_output(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>:: operator()(const X_monotone_curve_2& curve, const CoordinateType& x) -> CoordinateType { - CGAL::Object o; - CGAL::Oneset_iterator oi(o); Intersect_2 intersect = traits->intersect_2_object(); X_monotone_curve_2 c2 = this->makeVerticalLine(x); - intersect(curve, c2, oi); - std::pair res; - if (CGAL::assign(res, o)) { + typedef std::pair PtM; + + std::vector res; + intersect(curve, c2, CGAL::dispatch_or_drop_output(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; } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h index 488ed21dea7..50433fe8724 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_polycurve_traits_2.h @@ -826,7 +826,7 @@ public: std::get_if(&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 return_point;