diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/bezier_traits_adapter2.cpp b/Boolean_set_operations_2/examples/Boolean_set_operations_2/bezier_traits_adapter2.cpp index 853340f86d2..d99e287d40b 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/bezier_traits_adapter2.cpp +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/bezier_traits_adapter2.cpp @@ -3,6 +3,7 @@ */ #include +#include #ifndef CGAL_USE_CORE #include @@ -108,22 +109,13 @@ bool read_bezier(char const* aFileName, Bezier_polygon_set& rSet) for (unsigned int k = 0; k < n_curves; ++k) { // Read the current curve and subdivide it into x-monotone subcurves. - std::list x_objs; - std::list::const_iterator xoit; - Bezier_X_monotone_curve xcv; Bezier_traits traits; Bezier_traits::Make_x_monotone_2 make_x_monotone = traits.make_x_monotone_2_object(); Bezier_curve B = read_bezier_curve(in_file, lDoubleFormat); if (B.number_of_control_points() >= 2) { - - make_x_monotone(B, std::back_inserter(x_objs)); - - for (xoit = x_objs.begin(); xoit != x_objs.end(); ++xoit) { - if (CGAL::assign(xcv, *xoit)) - xcvs.push_back(xcv); - } + make_x_monotone(B, CGAL::dispatch_or_drop_output(std::back_inserter(xcvs))); } } diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp b/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp index 7cf3ec3dc7b..02bf08f58ca 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/circle_segment.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -24,22 +25,15 @@ typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2; // Construct a polygon from a circle. Polygon_2 construct_polygon (const Circle_2& circle) { - // Subdivide the circle into two x-monotone arcs. + // Subdivide the circle into two x-monotone arcs and construct the polygon. Traits_2 traits; Curve_2 curve (circle); - std::list objects; - traits.make_x_monotone_2_object() (curve, std::back_inserter(objects)); - assert(objects.size() == 2); - - // Construct the polygon. Polygon_2 pgn; - X_monotone_curve_2 arc; - std::list::iterator iter; - for (iter = objects.begin(); iter != objects.end(); ++iter) { - CGAL::assign (arc, *iter); - pgn.push_back (arc); - } + traits.make_x_monotone_2_object() (curve, + CGAL::dispatch_or_drop_output(std::back_inserter(pgn))); + std::cout << "size: " << pgn.size() << "\n"; + assert(pgn.size() == 2); return pgn; } diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/conic_traits_adapter.cpp b/Boolean_set_operations_2/examples/Boolean_set_operations_2/conic_traits_adapter.cpp index a35c90e29c6..f215b1a5267 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/conic_traits_adapter.cpp +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/conic_traits_adapter.cpp @@ -3,6 +3,7 @@ */ #include +#include #ifndef CGAL_USE_CORE #include @@ -42,14 +43,8 @@ typedef Traits_2::Point_2 Point_2; // sub-arcs and append these sub-arcs as polygon edges. void append_conic_arc(Polygon_2& polygon, const Curve_2& arc) { Conic_traits_2 traits; - std::list objects; - X_monotone_curve_2 xarc; - - traits.make_x_monotone_2_object() (arc, std::back_inserter(objects)); - for (auto it = objects.begin(); it != objects.end(); ++it) { - if (CGAL::assign (xarc, *it)) - polygon.push_back (xarc); - } + traits.make_x_monotone_2_object() (arc, + CGAL::dispatch_or_drop_output(std::back_inserter(polygon))); } int main() { diff --git a/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp b/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp index cecacc9a107..8ff0ced217f 100644 --- a/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp +++ b/Boolean_set_operations_2/examples/Boolean_set_operations_2/set_union.cpp @@ -25,22 +25,14 @@ typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2; // Construct a polygon from a circle. Polygon_2 construct_polygon (const Circle_2& circle) { - // Subdivide the circle into two x-monotone arcs. + // Subdivide the circle into two x-monotone arcs and construct the polygon Traits_2 traits; Curve_2 curve (circle); - std::list objects; - traits.make_x_monotone_2_object() (curve, std::back_inserter(objects)); - assert(objects.size() == 2); - - // Construct the polygon. Polygon_2 pgn; - X_monotone_curve_2 arc; - std::list::iterator iter; - for (iter = objects.begin(); iter != objects.end(); ++iter) { - CGAL::assign (arc, *iter); - pgn.push_back (arc); - } + traits.make_x_monotone_2_object() (curve, + CGAL::dispatch_or_drop_output(std::back_inserter(pgn))); + assert(pgn.size() == 2); return pgn; } diff --git a/Boolean_set_operations_2/include/CGAL/IO/Dxf_bsop_reader.h b/Boolean_set_operations_2/include/CGAL/IO/Dxf_bsop_reader.h index 1645afc1354..986ba9e86e1 100644 --- a/Boolean_set_operations_2/include/CGAL/IO/Dxf_bsop_reader.h +++ b/Boolean_set_operations_2/include/CGAL/IO/Dxf_bsop_reader.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace CGAL { @@ -97,29 +98,19 @@ public: typename Traits_2::Make_x_monotone_2 make_x_monotone = traits.make_x_monotone_2_object(); typename Dxf_circles_list::iterator circ_it; - CGAL::Object obj_vec[3]; - CGAL::Object *obj_begin = (obj_vec + 0); - CGAL::Object *obj_end; - X_monotone_curve_2 cv1, cv2; for (circ_it = circles.begin(); circ_it != circles.end(); ++circ_it) { // Break the circle into two x-monotone circular arcs. const Dxf_circle_2& dxf_circ = *circ_it; Curve_2 circ (dxf_circ.first, dxf_circ.second); - - obj_end = make_x_monotone (circ, obj_begin); - CGAL_assertion(obj_end - obj_begin == 2); - - CGAL::assign(cv1, obj_vec[0]); - CGAL::assign(cv2, obj_vec[1]); - - // Generate the corresponding polygon. Circ_polygon_2 pgn; - pgn.push_back (cv1); - pgn.push_back (cv2); - *pgns = pgn; - ++pgns; + + make_x_monotone (circ, + CGAL::dispatch_or_drop_output(std::back_inserter(pgn))); + CGAL_assertion(pgn.size() == 2); + + *pgns++ = pgn; } circles.clear(); @@ -131,8 +122,6 @@ public: typename Dxf_polygon_2::iterator curr, next; Point_2 ps, pt; Circle_2 supp_circ; - std::size_t n_subarcs; - std::size_t i; for (pgn_it = polygons.begin(); pgn_it != polygons.end(); ++pgn_it) { @@ -184,15 +173,8 @@ public: // Break the arc into x-monotone subarcs (there can be at most // three subarcs) and add them to the polygon. - obj_end = make_x_monotone (circ_arc, obj_begin); - n_subarcs = (obj_end - obj_begin); - CGAL_assertion (n_subarcs <= 3); - - for (i = 0; i < n_subarcs; i++) - { - if (CGAL::assign (cv1, obj_vec[i])) - pgn.push_back (cv1); - } + make_x_monotone (circ_arc, + CGAL::dispatch_or_drop_output(std::back_inserter(pgn))); } else {