diff --git a/src/svgfill/src/arrange_polygons.cpp b/src/svgfill/src/arrange_polygons.cpp index ba8785a267..4ffaa29068 100644 --- a/src/svgfill/src/arrange_polygons.cpp +++ b/src/svgfill/src/arrange_polygons.cpp @@ -135,9 +135,9 @@ T take_first_if_single_item(const std::vector& vec) { } template -boost::optional maybe_take_first_if_single_item(const std::vector& vec) { +std::optional maybe_take_first_if_single_item(const std::vector& vec) { if (vec.size() == 0) { - return boost::none; + return std::nullopt; } if (true || vec.size() == 1) { return vec.front(); @@ -145,9 +145,9 @@ boost::optional maybe_take_first_if_single_item(const std::vector& vec) { } template -boost::optional subtract_retain_largest(const T& lhs, const T& rhs) { +std::optional subtract_retain_largest(const T& lhs, const T& rhs) { std::vector result; - boost::optional mp; + std::optional mp; CGAL::difference(lhs, rhs, std::back_inserter(result)); @@ -157,12 +157,12 @@ boost::optional subtract_retain_largest(const T& lhs, const T& rhs) { if (result.size() > 0) { if (result.front().has_holes()) { - return boost::none; + return std::nullopt; } return result.front().outer_boundary(); } - return boost::none; + return std::nullopt; } Polygon_2 circ_to_poly(typename Arrangement_2::Ccb_halfedge_const_circulator circ) @@ -607,7 +607,7 @@ void eliminate_overlaps(DebugWriter& debug_writer, double OVERLAP_RESOLUTION_DIS { std::vector result; - boost::optional mp1, mp2, mp3, mp4; + std::optional mp1, mp2, mp3, mp4; bool swap = false; swap = poly1->area() <= poly2->area(); @@ -1410,18 +1410,18 @@ Point_2 project_point_to_line_exact(const Point_2& p, const MergedBoxRecord& box return box.exact_start + d * t; } -boost::optional intersect_infinite_lines_exact(const MergedBoxRecord& a, const MergedBoxRecord& b) { +std::optional intersect_infinite_lines_exact(const MergedBoxRecord& a, const MergedBoxRecord& b) { if (a.exact_start == a.exact_end || b.exact_start == b.exact_end) { - return boost::none; + return std::nullopt; } auto x = CGAL::intersection(CGAL::Line_2(a.exact_start, a.exact_end), CGAL::Line_2(b.exact_start, b.exact_end)); if (!x) { - return boost::none; + return std::nullopt; } if (auto* xp = variant_get(&*x)) { return *xp; } - return boost::none; + return std::nullopt; } double point_to_oriented_box_distance(const DPoint& p, const MergedBoxRecord& box) { @@ -1811,8 +1811,8 @@ void edge_slide(Graph2D& G) { } auto incoming = CGAL::Ray_2(other, neighbour - other); - boost::optional> closest_neighbouring_segment; - boost::optional> closest_intersection_point; + std::optional> closest_neighbouring_segment; + std::optional> closest_intersection_point; K::FT sq_distance_along_ray = std::numeric_limits::infinity(); for (auto vlt = vit->second.begin(); vlt != vit->second.end(); ++vlt) { @@ -1920,8 +1920,8 @@ std::list> extend_end_vertices_based_on_input( CGAL::Ray_2 ray(incoming, M - incoming); // intersect ray with boundary - boost::optional> closest_segment; - boost::optional> closest_intersection_point; + std::optional> closest_segment; + std::optional> closest_intersection_point; K::FT sq_distance_along_ray = std::numeric_limits::infinity(); for (auto jt = bnd.edges_begin(); jt != bnd.edges_end(); ++jt) { const auto& seg = *jt; @@ -1989,7 +1989,7 @@ std::list> extend_end_vertices_based_on_input( // Loop over boundary segments, and project point onto it, take the closest K::FT closest_distance = std::numeric_limits::infinity(); - boost::optional> closest_point; + std::optional> closest_point; for (auto& poly : outer_perimiter) { for (auto jt = poly.edges_begin(); jt != poly.edges_end(); ++jt) { auto seg = *jt; diff --git a/src/svgfill/src/main.cpp b/src/svgfill/src/main.cpp index 93ecfb6462..3806209ca0 100644 --- a/src/svgfill/src/main.cpp +++ b/src/svgfill/src/main.cpp @@ -21,7 +21,6 @@ #include "svgfill.h" #include "progress.h" -#include #include #include @@ -30,12 +29,13 @@ #include #include #include +#include int main(int argc, char** argv) { bool valid_command_line = false; bool random_color = false; double eps = 1.e-5; - boost::optional class_name; + std::optional class_name; std::vector flags; std::vector args; diff --git a/src/svgfill/src/svgfill.cpp b/src/svgfill/src/svgfill.cpp index cf45881c93..ed1d725766 100644 --- a/src/svgfill/src/svgfill.cpp +++ b/src/svgfill/src/svgfill.cpp @@ -48,7 +48,7 @@ private: svgfill::point_2 start_, xy_; public: - boost::optional class_name; + std::optional class_name; std::vector> segments; void on_enter_element(tag::element::any) @@ -59,7 +59,7 @@ public: void on_enter_element(tag::element::g) { ++depth_; - if (enabled_at_ == -1 && !class_name.is_initialized()) { + if (enabled_at_ == -1 && !class_name.has_value()) { enabled_at_ = depth_; segments.emplace_back(); } @@ -78,7 +78,7 @@ public: template void set(tag::attribute::class_, Str const & s) { - if (enabled_at_ == -1 && class_name.is_initialized() && std::string(s.begin(), s.size()).find(*class_name) != std::string::npos) { + if (enabled_at_ == -1 && class_name.has_value() && std::string(s.begin(), s.size()).find(*class_name) != std::string::npos) { enabled_at_ = depth_; segments.emplace_back(); } @@ -157,7 +157,7 @@ boost::mpl::fold< boost::mpl::insert >::type processed_attributes_t; -bool svgfill::svg_to_line_segments(const std::string& data, const boost::optional& class_name, std::vector>& segments) +bool svgfill::svg_to_line_segments(const std::string& data, const std::optional& class_name, std::vector>& segments) { Context context; context.class_name = class_name; @@ -187,7 +187,7 @@ bool svgfill::line_segments_to_polygons(solver s, double eps, const std::vector< return line_segments_to_polygons(s, eps, segments, polygons, fn); } -bool svgfill::svg_to_polygons(const std::string& data, const boost::optional& class_name, std::vector& polygons) { +bool svgfill::svg_to_polygons(const std::string& data, const std::optional& class_name, std::vector& polygons) { Context context; context.class_name = class_name; xmlDoc* doc = xmlReadMemory(data.c_str(), data.size(), nullptr, nullptr, 0); diff --git a/src/svgfill/src/svgfill.h b/src/svgfill/src/svgfill.h index 2588636a8d..e7b9028d00 100644 --- a/src/svgfill/src/svgfill.h +++ b/src/svgfill/src/svgfill.h @@ -35,10 +35,11 @@ #define SVGFILL_API #endif -#include - #include +#include #include +#include +#include namespace svgfill { typedef std::array point_2; @@ -109,12 +110,12 @@ namespace svgfill { } }; - SVGFILL_API bool svg_to_line_segments(const std::string& data, const boost::optional& class_name, std::vector>& segments); + SVGFILL_API bool svg_to_line_segments(const std::string& data, const std::optional& class_name, std::vector>& segments); SVGFILL_API bool line_segments_to_polygons(solver s, double eps, const std::vector>& segments, std::vector>& polygons); SVGFILL_API bool line_segments_to_polygons(solver s, double eps, const std::vector>& segments, std::vector>& polygons, std::function& progress); SVGFILL_API std::string polygons_to_svg(const std::vector>& polygons, bool random_color=false); SVGFILL_API std::string polygons_to_svg(const std::vector& polygons, bool random_color = false); - SVGFILL_API bool svg_to_polygons(const std::string& data, const boost::optional& class_name, std::vector& polygons); + SVGFILL_API bool svg_to_polygons(const std::string& data, const std::optional& class_name, std::vector& polygons); struct SVGFILL_API arrange_polygon_settings { bool debug_output = false;