From cbdef879cb7d14e872346917cb5e290bfb8c2f1f Mon Sep 17 00:00:00 2001 From: aismann Date: Sat, 1 Feb 2025 22:37:39 +0100 Subject: [PATCH] Clipper2 1.5.2 (#2360) Clipper2_1.5.2 Changes (since Ver 1.5.0) CPP: tidied file header includes (#940) CPP: emplace_back() replaces many push_back() (#939) Fixed typos and broken links (#936) --- 3rdparty/README.md | 2 +- .../clipper2/include/clipper2/clipper.core.h | 27 +++---- .../include/clipper2/clipper.engine.h | 12 +-- .../include/clipper2/clipper.export.h | 29 ++++---- 3rdparty/clipper2/include/clipper2/clipper.h | 35 ++++----- .../include/clipper2/clipper.minkowski.h | 21 +++--- .../include/clipper2/clipper.offset.h | 5 +- .../include/clipper2/clipper.rectclip.h | 8 +- .../include/clipper2/clipper.version.h | 2 +- 3rdparty/clipper2/src/clipper.engine.cpp | 68 ++++++++--------- 3rdparty/clipper2/src/clipper.offset.cpp | 73 +++++++++---------- 3rdparty/clipper2/src/clipper.rectclip.cpp | 31 ++++---- 12 files changed, 142 insertions(+), 171 deletions(-) diff --git a/3rdparty/README.md b/3rdparty/README.md index 42897fbea9ff..7e6624330ffd 100644 --- a/3rdparty/README.md +++ b/3rdparty/README.md @@ -32,7 +32,7 @@ ## Clipper2 - [![Upstream](https://img.shields.io/github/v/tag/AngusJohnson/Clipper2?label=Upstream)](https://github.com/AngusJohnson/Clipper2) -- Version: 1.5.0 +- Version: 1.5.2 - License: BSL-1.0 ## ConcurrentQueue diff --git a/3rdparty/clipper2/include/clipper2/clipper.core.h b/3rdparty/clipper2/include/clipper2/clipper.core.h index 624de9032625..ab71aeb0727a 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.core.h +++ b/3rdparty/clipper2/include/clipper2/clipper.core.h @@ -1,26 +1,23 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 12 May 2024 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : Core Clipper Library structures and functions * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ #ifndef CLIPPER_CORE_H #define CLIPPER_CORE_H +#include "clipper2/clipper.version.h" #include -#include -#include #include #include #include #include -#include #include -#include -#include "clipper2/clipper.version.h" +#include namespace Clipper2Lib { @@ -331,10 +328,10 @@ namespace Clipper2Lib { Path result; result.reserve(4); - result.push_back(Point(left, top)); - result.push_back(Point(right, top)); - result.push_back(Point(right, bottom)); - result.push_back(Point(left, bottom)); + result.emplace_back(left, top); + result.emplace_back(right, top); + result.emplace_back(right, bottom); + result.emplace_back(left, bottom); return result; } @@ -618,13 +615,13 @@ namespace Clipper2Lib result.reserve(path.size()); typename Path::const_iterator path_iter = path.cbegin(); Point first_pt = *path_iter++, last_pt = first_pt; - result.push_back(first_pt); + result.emplace_back(first_pt); for (; path_iter != path.cend(); ++path_iter) { if (!NearEqual(*path_iter, last_pt, max_dist_sqrd)) { last_pt = *path_iter; - result.push_back(last_pt); + result.emplace_back(last_pt); } } if (!is_closed_path) return result; @@ -642,7 +639,7 @@ namespace Clipper2Lib for (typename Paths::const_iterator paths_citer = paths.cbegin(); paths_citer != paths.cend(); ++paths_citer) { - result.push_back(StripNearEqual(*paths_citer, max_dist_sqrd, is_closed_path)); + result.emplace_back(std::move(StripNearEqual(*paths_citer, max_dist_sqrd, is_closed_path))); } return result; } @@ -787,7 +784,7 @@ namespace Clipper2Lib const Point& line1, const Point& line2) { //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²) - //see http://en.wikipedia.org/wiki/Perpendicular_distance + //see https://en.wikipedia.org/wiki/Perpendicular_distance double a = static_cast(pt.x - line1.x); double b = static_cast(pt.y - line1.y); double c = static_cast(line2.x - line1.x); diff --git a/3rdparty/clipper2/include/clipper2/clipper.engine.h b/3rdparty/clipper2/include/clipper2/clipper.engine.h index 8129beb01e76..f4e1e1838590 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.engine.h +++ b/3rdparty/clipper2/include/clipper2/clipper.engine.h @@ -1,26 +1,20 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 17 September 2024 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : This is the main polygon clipping module * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ #ifndef CLIPPER_ENGINE_H #define CLIPPER_ENGINE_H -#include -#include //#541 -#include +#include "clipper2/clipper.core.h" #include -#include #include -#include #include -#include "clipper2/clipper.core.h" - namespace Clipper2Lib { struct Scanline; diff --git a/3rdparty/clipper2/include/clipper2/clipper.export.h b/3rdparty/clipper2/include/clipper2/clipper.export.h index 1642d1f50857..79856e2eb562 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.export.h +++ b/3rdparty/clipper2/include/clipper2/clipper.export.h @@ -1,10 +1,10 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 24 January 2025 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2025 * * Purpose : This module exports the Clipper2 Library (ie DLL/so) * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ @@ -53,7 +53,7 @@ _______________________________________________________________ CPaths64 and CPathsD: These are also arrays of either int64_t or double values that contain any number of consecutive CPath structures. However, -preceeding the first path is a pair of values. The first value +preceding the first path is a pair of values. The first value contains the length of the entire array structure (A), and the second contains the number (ie count) of contained paths (C). Memory allocation for CPaths64 = A * sizeof(int64_t) @@ -112,12 +112,11 @@ the four vertices that define the two segments that are intersecting. #ifndef CLIPPER2_EXPORT_H #define CLIPPER2_EXPORT_H -#include -#include #include "clipper2/clipper.core.h" #include "clipper2/clipper.engine.h" #include "clipper2/clipper.offset.h" #include "clipper2/clipper.rectclip.h" +#include namespace Clipper2Lib { @@ -392,9 +391,9 @@ static Path ConvertCPathToPathT(T* path) T x = *v++, y = *v++; #ifdef USINGZ z_type z = Reinterpret(*v++); - result.push_back(Point(x, y, z)); + result.emplace_back(x, y, z); #else - result.push_back(Point(x, y)); + result.emplace_back(x, y); #endif } return result; @@ -419,12 +418,12 @@ static Paths ConvertCPathsToPathsT(T* paths) T x = *v++, y = *v++; #ifdef USINGZ z_type z = Reinterpret(*v++); - path.push_back(Point(x, y, z)); + path.emplace_back(x, y, z); #else - path.push_back(Point(x, y)); + path.emplace_back(x, y); #endif } - result.push_back(path); + result.emplace_back(std::move(path)); } return result; } @@ -443,9 +442,9 @@ static Path64 ConvertCPathDToPath64WithScale(const CPathD path, double scale) double y = *v++ * scale; #ifdef USINGZ z_type z = Reinterpret(*v++); - result.push_back(Point64(x, y, z)); + result.emplace_back(x, y, z); #else - result.push_back(Point64(x, y)); + result.emplace_back(x, y); #endif } return result; @@ -471,12 +470,12 @@ static Paths64 ConvertCPathsDToPaths64(const CPathsD paths, double scale) double y = *v++ * scale; #ifdef USINGZ z_type z = Reinterpret(*v++); - path.push_back(Point64(x, y, z)); + path.emplace_back(x, y, z); #else - path.push_back(Point64(x, y)); + path.emplace_back(x, y); #endif } - result.push_back(path); + result.emplace_back(std::move(path)); } return result; } diff --git a/3rdparty/clipper2/include/clipper2/clipper.h b/3rdparty/clipper2/include/clipper2/clipper.h index a2fe5c3cc28f..b75bbd353237 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.h +++ b/3rdparty/clipper2/include/clipper2/clipper.h @@ -1,24 +1,21 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 27 April 2024 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : This module provides a simple interface to the Clipper Library * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ #ifndef CLIPPER_H #define CLIPPER_H -#include -#include -#include - #include "clipper2/clipper.core.h" #include "clipper2/clipper.engine.h" #include "clipper2/clipper.offset.h" #include "clipper2/clipper.minkowski.h" #include "clipper2/clipper.rectclip.h" +#include namespace Clipper2Lib { @@ -272,14 +269,14 @@ namespace Clipper2Lib { inline void PolyPathToPaths64(const PolyPath64& polypath, Paths64& paths) { - paths.push_back(polypath.Polygon()); + paths.emplace_back(polypath.Polygon()); for (const auto& child : polypath) PolyPathToPaths64(*child, paths); } inline void PolyPathToPathsD(const PolyPathD& polypath, PathsD& paths) { - paths.push_back(polypath.Polygon()); + paths.emplace_back(polypath.Polygon()); for (const auto& child : polypath) PolyPathToPathsD(*child, paths); } @@ -348,9 +345,9 @@ namespace Clipper2Lib { result.reserve(array_size / 2); for (size_t i = 0; i < array_size; i +=2) #ifdef USINGZ - result.push_back( U{ an_array[i], an_array[i + 1], 0} ); + result.emplace_back( an_array[i], an_array[i + 1], 0 ); #else - result.push_back( U{ an_array[i], an_array[i + 1]} ); + result.emplace_back( an_array[i], an_array[i + 1] ); #endif } @@ -518,20 +515,20 @@ namespace Clipper2Lib { } prevIt = srcIt++; - dst.push_back(*prevIt); + dst.emplace_back(*prevIt); for (; srcIt != stop; ++srcIt) { if (!IsCollinear(*prevIt, *srcIt, *(srcIt + 1))) { prevIt = srcIt; - dst.push_back(*prevIt); + dst.emplace_back(*prevIt); } } if (is_open_path) - dst.push_back(*srcIt); + dst.emplace_back(*srcIt); else if (!IsCollinear(*prevIt, *stop, dst[0])) - dst.push_back(*stop); + dst.emplace_back(*stop); else { while (dst.size() > 2 && @@ -603,10 +600,10 @@ namespace Clipper2Lib { double dx = co, dy = si; Path result; result.reserve(steps); - result.push_back(Point(center.x + radiusX, static_cast(center.y))); + result.emplace_back(center.x + radiusX, static_cast(center.y)); for (size_t i = 1; i < steps; ++i) { - result.push_back(Point(center.x + radiusX * dx, center.y + radiusY * dy)); + result.emplace_back(center.x + radiusX * dx, center.y + radiusY * dy); double x = dx * co - dy * si; dy = dy * co + dx * si; dx = x; @@ -700,7 +697,7 @@ namespace Clipper2Lib { Path result; result.reserve(len); for (typename Path::size_type i = 0; i < len; ++i) - if (!flags[i]) result.push_back(path[i]); + if (!flags[i]) result.emplace_back(path[i]); return result; } @@ -711,7 +708,7 @@ namespace Clipper2Lib { Paths result; result.reserve(paths.size()); for (const auto& path : paths) - result.push_back(SimplifyPath(path, epsilon, isClosedPath)); + result.emplace_back(std::move(SimplifyPath(path, epsilon, isClosedPath))); return result; } @@ -749,7 +746,7 @@ namespace Clipper2Lib { result.reserve(len); for (typename Path::size_type i = 0; i < len; ++i) if (flags[i]) - result.push_back(path[i]); + result.emplace_back(path[i]); return result; } diff --git a/3rdparty/clipper2/include/clipper2/clipper.minkowski.h b/3rdparty/clipper2/include/clipper2/clipper.minkowski.h index a3ddcf86f3a4..3a85ba5d1e7e 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.minkowski.h +++ b/3rdparty/clipper2/include/clipper2/clipper.minkowski.h @@ -1,18 +1,15 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 1 November 2023 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2023 * * Purpose : Minkowski Sum and Difference * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ #ifndef CLIPPER_MINKOWSKI_H #define CLIPPER_MINKOWSKI_H -#include -#include -#include #include "clipper2/clipper.core.h" namespace Clipper2Lib @@ -35,7 +32,7 @@ namespace Clipper2Lib Path64 path2(pattern.size()); std::transform(pattern.cbegin(), pattern.cend(), path2.begin(), [p](const Point64& pt2) {return p + pt2; }); - tmp.push_back(path2); + tmp.emplace_back(std::move(path2)); } } else @@ -45,7 +42,7 @@ namespace Clipper2Lib Path64 path2(pattern.size()); std::transform(pattern.cbegin(), pattern.cend(), path2.begin(), [p](const Point64& pt2) {return p - pt2; }); - tmp.push_back(path2); + tmp.emplace_back(std::move(path2)); } } @@ -59,14 +56,14 @@ namespace Clipper2Lib Path64 quad; quad.reserve(4); { - quad.push_back(tmp[g][h]); - quad.push_back(tmp[i][h]); - quad.push_back(tmp[i][j]); - quad.push_back(tmp[g][j]); + quad.emplace_back(tmp[g][h]); + quad.emplace_back(tmp[i][h]); + quad.emplace_back(tmp[i][j]); + quad.emplace_back(tmp[g][j]); }; if (!IsPositive(quad)) std::reverse(quad.begin(), quad.end()); - result.push_back(quad); + result.emplace_back(std::move(quad)); h = j; } g = i; diff --git a/3rdparty/clipper2/include/clipper2/clipper.offset.h b/3rdparty/clipper2/include/clipper2/clipper.offset.h index c0ec99ddd05c..90ccd5ec9775 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.offset.h +++ b/3rdparty/clipper2/include/clipper2/clipper.offset.h @@ -1,10 +1,10 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 22 January 2025 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2025 * * Purpose : Path Offset (Inflate/Shrink) * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ #ifndef CLIPPER_OFFSET_H_ @@ -12,6 +12,7 @@ #include "clipper.core.h" #include "clipper.engine.h" +#include namespace Clipper2Lib { diff --git a/3rdparty/clipper2/include/clipper2/clipper.rectclip.h b/3rdparty/clipper2/include/clipper2/clipper.rectclip.h index bfcfacf2e7c9..e7cf2f45423f 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.rectclip.h +++ b/3rdparty/clipper2/include/clipper2/clipper.rectclip.h @@ -1,19 +1,17 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 5 July 2024 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : FAST rectangular clipping * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ #ifndef CLIPPER_RECTCLIP_H #define CLIPPER_RECTCLIP_H -#include -#include -#include #include "clipper2/clipper.core.h" +#include namespace Clipper2Lib { diff --git a/3rdparty/clipper2/include/clipper2/clipper.version.h b/3rdparty/clipper2/include/clipper2/clipper.version.h index 130b4c97b26c..661b0f1c5881 100644 --- a/3rdparty/clipper2/include/clipper2/clipper.version.h +++ b/3rdparty/clipper2/include/clipper2/clipper.version.h @@ -1,6 +1,6 @@ #ifndef CLIPPER_VERSION_H #define CLIPPER_VERSION_H -constexpr auto CLIPPER2_VERSION = "1.5.0"; +constexpr auto CLIPPER2_VERSION = "1.5.2"; #endif // CLIPPER_VERSION_H diff --git a/3rdparty/clipper2/src/clipper.engine.cpp b/3rdparty/clipper2/src/clipper.engine.cpp index 97717322c5ff..927e7a758091 100644 --- a/3rdparty/clipper2/src/clipper.engine.cpp +++ b/3rdparty/clipper2/src/clipper.engine.cpp @@ -1,21 +1,15 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 17 September 2024 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : This is the main polygon clipping module * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ -#include -#include -#include -#include -#include -#include - #include "clipper2/clipper.engine.h" #include "clipper2/clipper.h" +#include // https://github.com/AngusJohnson/Clipper2/discussions/334 // #discussioncomment-4248602 @@ -517,7 +511,7 @@ namespace Clipper2Lib { while (op2 != op && op2->pt.y > pt.y) op2 = op2->next; if (op2 == op) break; - // must have touched or crossed the pt.Y horizonal + // must have touched or crossed the pt.Y horizontal // and this must happen an even number of times if (op2->pt.y == pt.y) // touching the horizontal @@ -564,7 +558,7 @@ namespace Clipper2Lib { while (op2->next != op && ((op2->pt.x == op2->next->pt.x && op2->pt.x == op2->prev->pt.x) || (op2->pt.y == op2->next->pt.y && op2->pt.y == op2->prev->pt.y))) op2 = op2->next; - result.push_back(op2->pt); + result.emplace_back(op2->pt); OutPt* prevOp = op2; op2 = op2->next; while (op2 != op) @@ -572,7 +566,7 @@ namespace Clipper2Lib { if ((op2->pt.x != op2->next->pt.x || op2->pt.x != prevOp->pt.x) && (op2->pt.y != op2->next->pt.y || op2->pt.y != prevOp->pt.y)) { - result.push_back(op2->pt); + result.emplace_back(op2->pt); prevOp = op2; } op2 = op2->next; @@ -611,7 +605,7 @@ namespace Clipper2Lib { if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return; vert.flags = (vert.flags | VertexFlags::LocalMin); - list.push_back(std::make_unique (&vert, polytype, is_open)); + list.emplace_back(std::make_unique (&vert, polytype, is_open)); } void AddPaths_(const Paths64& paths, PathType polytype, bool is_open, @@ -728,7 +722,7 @@ namespace Clipper2Lib { if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return; vert.flags = (vert.flags | VertexFlags::LocalMin); - minima_list_.push_back(std::make_unique (&vert, polytype, is_open)); + minima_list_.emplace_back(std::make_unique (&vert, polytype, is_open)); } void ReuseableDataContainer64::AddPaths(const Paths64& paths, @@ -836,9 +830,7 @@ namespace Clipper2Lib { void ClipperBase::AddPath(const Path64& path, PathType polytype, bool is_open) { - Paths64 tmp; - tmp.push_back(path); - AddPaths(tmp, polytype, is_open); + AddPaths(Paths64(1, path), polytype, is_open); } void ClipperBase::AddPaths(const Paths64& paths, PathType polytype, bool is_open) @@ -857,7 +849,7 @@ namespace Clipper2Lib { LocalMinimaList::const_iterator i; for (i = reuseable_data.minima_list_.cbegin(); i != reuseable_data.minima_list_.cend(); ++i) { - minima_list_.push_back(std::make_unique ((*i)->vertex, (*i)->polytype, (*i)->is_open)); + minima_list_.emplace_back(std::make_unique ((*i)->vertex, (*i)->polytype, (*i)->is_open)); if ((*i)->is_open) has_open_paths_ = true; } } @@ -910,7 +902,7 @@ namespace Clipper2Lib { if ((VertexFlags::LocalMin & vert.flags) != VertexFlags::Empty) return; vert.flags = (vert.flags | VertexFlags::LocalMin); - minima_list_.push_back(std::make_unique (&vert, polytype, is_open)); + minima_list_.emplace_back(std::make_unique (&vert, polytype, is_open)); } bool ClipperBase::IsContributingClosed(const Active& e) const @@ -1494,7 +1486,7 @@ namespace Clipper2Lib { { OutRec* result = new OutRec(); result->idx = outrec_list_.size(); - outrec_list_.push_back(result); + outrec_list_.emplace_back(result); result->pts = nullptr; result->owner = nullptr; result->polypath = nullptr; @@ -1637,12 +1629,12 @@ namespace Clipper2Lib { if (Path1InsidePath2(prevOp, newOp)) { newOr->splits = new OutRecList(); - newOr->splits->push_back(outrec); + newOr->splits->emplace_back(outrec); } else { if (!outrec->splits) outrec->splits = new OutRecList(); - outrec->splits->push_back(newOr); + outrec->splits->emplace_back(newOr); } } } @@ -1961,7 +1953,7 @@ namespace Clipper2Lib { else if (IsFront(e1) || (e1.outrec == e2.outrec)) { //this 'else if' condition isn't strictly needed but - //it's sensible to split polygons that ony touch at + //it's sensible to split polygons that only touch at //a common vertex (not at common edges). #ifdef USINGZ @@ -2245,7 +2237,7 @@ namespace Clipper2Lib { HorzJoin join = HorzJoin( DuplicateOp(hs1->left_op, true), DuplicateOp(hs2->left_op, false)); - horz_join_list_.push_back(join); + horz_join_list_.emplace_back(join); } else { @@ -2258,7 +2250,7 @@ namespace Clipper2Lib { HorzJoin join = HorzJoin( DuplicateOp(hs2->left_op, true), DuplicateOp(hs1->left_op, false)); - horz_join_list_.push_back(join); + horz_join_list_.emplace_back(join); } } } @@ -2270,7 +2262,7 @@ namespace Clipper2Lib { if (!toOr->splits) toOr->splits = new OutRecList(); OutRecList::iterator orIter = fromOr->splits->begin(); for (; orIter != fromOr->splits->end(); ++orIter) - toOr->splits->push_back(*orIter); + toOr->splits->emplace_back(*orIter); fromOr->splits->clear(); } @@ -2323,7 +2315,7 @@ namespace Clipper2Lib { or2->owner = or1->owner; if (!or1->splits) or1->splits = new OutRecList(); - or1->splits->push_back(or2); + or1->splits->emplace_back(or2); } else or2->owner = or1; @@ -2382,7 +2374,7 @@ namespace Clipper2Lib { else ip.x = TopX(e2, ip.y); } } - intersect_nodes_.push_back(IntersectNode(&e1, &e2, ip)); + intersect_nodes_.emplace_back(&e1, &e2, ip); } bool ClipperBase::BuildIntersectList(const int64_t top_y) @@ -2503,7 +2495,7 @@ namespace Clipper2Lib { void ClipperBase::AddTrialHorzJoin(OutPt* op) { if (op->outrec->is_open) return; - horz_seg_list_.push_back(HorzSegment(op)); + horz_seg_list_.emplace_back(op); } bool ClipperBase::ResetHorzDirection(const Active& horz, @@ -2661,7 +2653,7 @@ namespace Clipper2Lib { if (horz.outrec) { - //nb: The outrec containining the op returned by IntersectEdges + //nb: The outrec containing the op returned by IntersectEdges //above may no longer be associated with horzEdge. AddTrialHorzJoin(GetLastOp(horz)); } @@ -2905,14 +2897,14 @@ namespace Clipper2Lib { lastPt = op->pt; op2 = op->next; } - path.push_back(lastPt); + path.emplace_back(lastPt); while (op2 != op) { if (op2->pt != lastPt) { lastPt = op2->pt; - path.push_back(lastPt); + path.emplace_back(lastPt); } if (reverse) op2 = op2->prev; @@ -3037,7 +3029,7 @@ namespace Clipper2Lib { { Path64 path; if (BuildPath64(outrec->pts, reverse_solution_, true, path)) - open_paths.push_back(path); + open_paths.emplace_back(std::move(path)); continue; } @@ -3066,9 +3058,9 @@ namespace Clipper2Lib { op2 = op->next; } #ifdef USINGZ - path.push_back(PointD(lastPt.x * inv_scale, lastPt.y * inv_scale, lastPt.z)); + path.emplace_back(lastPt.x * inv_scale, lastPt.y * inv_scale, lastPt.z); #else - path.push_back(PointD(lastPt.x * inv_scale, lastPt.y * inv_scale)); + path.emplace_back(lastPt.x * inv_scale, lastPt.y * inv_scale); #endif while (op2 != op) @@ -3077,9 +3069,9 @@ namespace Clipper2Lib { { lastPt = op2->pt; #ifdef USINGZ - path.push_back(PointD(lastPt.x * inv_scale, lastPt.y * inv_scale, lastPt.z)); + path.emplace_back(lastPt.x * inv_scale, lastPt.y * inv_scale, lastPt.z); #else - path.push_back(PointD(lastPt.x * inv_scale, lastPt.y * inv_scale)); + path.emplace_back(lastPt.x * inv_scale, lastPt.y * inv_scale); #endif } @@ -3143,7 +3135,7 @@ namespace Clipper2Lib { { PathD path; if (BuildPathD(outrec->pts, reverse_solution_, true, path, invScale_)) - open_paths.push_back(path); + open_paths.emplace_back(std::move(path)); continue; } diff --git a/3rdparty/clipper2/src/clipper.offset.cpp b/3rdparty/clipper2/src/clipper.offset.cpp index 7f54f28a25ae..23e405ed1d58 100644 --- a/3rdparty/clipper2/src/clipper.offset.cpp +++ b/3rdparty/clipper2/src/clipper.offset.cpp @@ -1,13 +1,12 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 22 January 2025 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2025 * * Purpose : Path Offset (Inflate/Shrink) * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ -#include #include "clipper2/clipper.h" #include "clipper2/clipper.offset.h" @@ -161,15 +160,13 @@ ClipperOffset::Group::Group(const Paths64& _paths, JoinType _join_type, EndType void ClipperOffset::AddPath(const Path64& path, JoinType jt_, EndType et_) { - Paths64 paths; - paths.push_back(path); - AddPaths(paths, jt_, et_); + groups_.emplace_back(Paths64(1, path), jt_, et_); } void ClipperOffset::AddPaths(const Paths64 &paths, JoinType jt_, EndType et_) { if (paths.size() == 0) return; - groups_.push_back(Group(paths, jt_, et_)); + groups_.emplace_back(paths, jt_, et_); } void ClipperOffset::BuildNormals(const Path64& path) @@ -179,8 +176,8 @@ void ClipperOffset::BuildNormals(const Path64& path) if (path.size() == 0) return; Path64::const_iterator path_iter, path_stop_iter = --path.cend(); for (path_iter = path.cbegin(); path_iter != path_stop_iter; ++path_iter) - norms.push_back(GetUnitNormal(*path_iter,*(path_iter +1))); - norms.push_back(GetUnitNormal(*path_stop_iter, *(path.cbegin()))); + norms.emplace_back(GetUnitNormal(*path_iter,*(path_iter +1))); + norms.emplace_back(GetUnitNormal(*path_stop_iter, *(path.cbegin()))); } void ClipperOffset::DoBevel(const Path64& path, size_t j, size_t k) @@ -207,8 +204,8 @@ void ClipperOffset::DoBevel(const Path64& path, size_t j, size_t k) pt2 = PointD(path[j].x + group_delta_ * norms[j].x, path[j].y + group_delta_ * norms[j].y); #endif } - path_out.push_back(Point64(pt1)); - path_out.push_back(Point64(pt2)); + path_out.emplace_back(pt1); + path_out.emplace_back(pt2); } void ClipperOffset::DoSquare(const Path64& path, size_t j, size_t k) @@ -237,17 +234,17 @@ void ClipperOffset::DoSquare(const Path64& path, size_t j, size_t k) PointD pt = ptQ; GetSegmentIntersectPt(pt1, pt2, pt3, pt4, pt); //get the second intersect point through reflecion - path_out.push_back(Point64(ReflectPoint(pt, ptQ))); - path_out.push_back(Point64(pt)); + path_out.emplace_back(ReflectPoint(pt, ptQ)); + path_out.emplace_back(pt); } else { PointD pt4 = GetPerpendicD(path[j], norms[k], group_delta_); PointD pt = ptQ; GetSegmentIntersectPt(pt1, pt2, pt3, pt4, pt); - path_out.push_back(Point64(pt)); + path_out.emplace_back(pt); //get the second intersect point through reflecion - path_out.push_back(Point64(ReflectPoint(pt, ptQ))); + path_out.emplace_back(ReflectPoint(pt, ptQ)); } } @@ -255,14 +252,14 @@ void ClipperOffset::DoMiter(const Path64& path, size_t j, size_t k, double cos_a { double q = group_delta_ / (cos_a + 1); #ifdef USINGZ - path_out.push_back(Point64( + path_out.emplace_back( path[j].x + (norms[k].x + norms[j].x) * q, path[j].y + (norms[k].y + norms[j].y) * q, - path[j].z)); + path[j].z); #else - path_out.push_back(Point64( + path_out.emplace_back( path[j].x + (norms[k].x + norms[j].x) * q, - path[j].y + (norms[k].y + norms[j].y) * q)); + path[j].y + (norms[k].y + norms[j].y) * q); #endif } @@ -286,9 +283,9 @@ void ClipperOffset::DoRound(const Path64& path, size_t j, size_t k, double angle if (j == k) offsetVec.Negate(); #ifdef USINGZ - path_out.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y, pt.z)); + path_out.emplace_back(pt.x + offsetVec.x, pt.y + offsetVec.y, pt.z); #else - path_out.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y)); + path_out.emplace_back(pt.x + offsetVec.x, pt.y + offsetVec.y); #endif int steps = static_cast(std::ceil(steps_per_rad_ * std::abs(angle))); // #448, #456 for (int i = 1; i < steps; ++i) // ie 1 less than steps @@ -296,12 +293,12 @@ void ClipperOffset::DoRound(const Path64& path, size_t j, size_t k, double angle offsetVec = PointD(offsetVec.x * step_cos_ - step_sin_ * offsetVec.y, offsetVec.x * step_sin_ + offsetVec.y * step_cos_); #ifdef USINGZ - path_out.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y, pt.z)); + path_out.emplace_back(pt.x + offsetVec.x, pt.y + offsetVec.y, pt.z); #else - path_out.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y)); + path_out.emplace_back(pt.x + offsetVec.x, pt.y + offsetVec.y); #endif } - path_out.push_back(GetPerpendic(path[j], norms[j], group_delta_)); + path_out.emplace_back(GetPerpendic(path[j], norms[j], group_delta_)); } void ClipperOffset::OffsetPoint(Group& group, const Path64& path, size_t j, size_t k) @@ -325,7 +322,7 @@ void ClipperOffset::OffsetPoint(Group& group, const Path64& path, size_t j, size } if (std::fabs(group_delta_) <= floating_point_tolerance) { - path_out.push_back(path[j]); + path_out.emplace_back(path[j]); return; } @@ -337,13 +334,13 @@ void ClipperOffset::OffsetPoint(Group& group, const Path64& path, size_t j, size // will be removed later by the finishing union operation. This is also the best way // to ensure that path reversals (ie over-shrunk paths) are removed. #ifdef USINGZ - path_out.push_back(Point64(GetPerpendic(path[j], norms[k], group_delta_), path[j].z)); - path_out.push_back(path[j]); // (#405, #873, #916) - path_out.push_back(Point64(GetPerpendic(path[j], norms[j], group_delta_), path[j].z)); + path_out.emplace_back(GetPerpendic(path[j], norms[k], group_delta_), path[j].z); + path_out.emplace_back(path[j]); // (#405, #873, #916) + path_out.emplace_back(GetPerpendic(path[j], norms[j], group_delta_), path[j].z); #else - path_out.push_back(GetPerpendic(path[j], norms[k], group_delta_)); - path_out.push_back(path[j]); // (#405, #873, #916) - path_out.push_back(GetPerpendic(path[j], norms[j], group_delta_)); + path_out.emplace_back(GetPerpendic(path[j], norms[k], group_delta_)); + path_out.emplace_back(path[j]); // (#405, #873, #916) + path_out.emplace_back(GetPerpendic(path[j], norms[j], group_delta_)); #endif } else if (cos_a > 0.999 && join_type_ != JoinType::Round) @@ -370,7 +367,7 @@ void ClipperOffset::OffsetPolygon(Group& group, const Path64& path) path_out.clear(); for (Path64::size_type j = 0, k = path.size() - 1; j < path.size(); k = j, ++j) OffsetPoint(group, path, j, k); - solution->push_back(path_out); + solution->emplace_back(path_out); } void ClipperOffset::OffsetOpenJoined(Group& group, const Path64& path) @@ -381,7 +378,7 @@ void ClipperOffset::OffsetOpenJoined(Group& group, const Path64& path) //rebuild normals std::reverse(norms.begin(), norms.end()); - norms.push_back(norms[0]); + norms.emplace_back(norms[0]); norms.erase(norms.begin()); NegatePath(norms); @@ -394,7 +391,7 @@ void ClipperOffset::OffsetOpenPath(Group& group, const Path64& path) if (deltaCallback64_) group_delta_ = deltaCallback64_(path, norms, 0, 0); if (std::fabs(group_delta_) <= floating_point_tolerance) - path_out.push_back(path[0]); + path_out.emplace_back(path[0]); else { switch (end_type_) @@ -426,7 +423,7 @@ void ClipperOffset::OffsetOpenPath(Group& group, const Path64& path) group_delta_ = deltaCallback64_(path, norms, highI, highI); if (std::fabs(group_delta_) <= floating_point_tolerance) - path_out.push_back(path[highI]); + path_out.emplace_back(path[highI]); else { switch (end_type_) @@ -445,7 +442,7 @@ void ClipperOffset::OffsetOpenPath(Group& group, const Path64& path) for (size_t j = highI -1, k = highI; j > 0; k = j, --j) OffsetPoint(group, path, j, k); - solution->push_back(path_out); + solution->emplace_back(path_out); } void ClipperOffset::DoGroupOffset(Group& group) @@ -467,7 +464,7 @@ void ClipperOffset::DoGroupOffset(Group& group) if (group.join_type == JoinType::Round || group.end_type == EndType::Round) { // calculate the number of steps required to approximate a circle - // (see http://www.angusj.com/clipper2/Docs/Trigonometry.htm) + // (see https://www.angusj.com/clipper2/Docs/Trigonometry.htm) // arcTol - when arc_tolerance_ is undefined (0) then curve imprecision // will be relative to the size of the offset (delta). Obviously very //large offsets will almost always require much less precision. @@ -519,7 +516,7 @@ void ClipperOffset::DoGroupOffset(Group& group) #endif } - solution->push_back(path_out); + solution->emplace_back(path_out); continue; } // end of offsetting a single point diff --git a/3rdparty/clipper2/src/clipper.rectclip.cpp b/3rdparty/clipper2/src/clipper.rectclip.cpp index 23809b5ef6bf..a5d66df4630c 100644 --- a/3rdparty/clipper2/src/clipper.rectclip.cpp +++ b/3rdparty/clipper2/src/clipper.rectclip.cpp @@ -1,13 +1,12 @@ /******************************************************************************* * Author : Angus Johnson * * Date : 5 July 2024 * -* Website : http://www.angusj.com * +* Website : https://www.angusj.com * * Copyright : Angus Johnson 2010-2024 * * Purpose : FAST rectangular clipping * -* License : http://www.boost.org/LICENSE_1_0.txt * +* License : https://www.boost.org/LICENSE_1_0.txt * *******************************************************************************/ -#include #include "clipper2/clipper.h" #include "clipper2/clipper.rectclip.h" @@ -282,7 +281,7 @@ namespace Clipper2Lib { { if (op->edge) return; op->edge = &edge; - edge.push_back(op); + edge.emplace_back(op); } inline void UncoupleEdge(OutPt2* op) @@ -328,7 +327,7 @@ namespace Clipper2Lib { result->pt = pt; result->next = result; result->prev = result; - results_.push_back(result); + results_.emplace_back(result); } else { @@ -489,7 +488,7 @@ namespace Clipper2Lib { { bool isClockw = IsClockwise(prev, loc, prev_pt, path[i], rect_mp_); do { - start_locs_.push_back(prev); + start_locs_.emplace_back(prev); prev = GetAdjacentLocation(prev, isClockw); } while (prev != loc); crossing_loc = crossing_prev; // still not crossed @@ -514,7 +513,7 @@ namespace Clipper2Lib { if (first_cross_ == Location::Inside) { first_cross_ = crossing_loc; - start_locs_.push_back(prev); + start_locs_.emplace_back(prev); } else if (prev != crossing_loc) { @@ -536,7 +535,7 @@ namespace Clipper2Lib { if (first_cross_ == Location::Inside) { first_cross_ = loc; - start_locs_.push_back(prev); + start_locs_.emplace_back(prev); } loc = crossing_loc; @@ -750,7 +749,7 @@ namespace Clipper2Lib { if (!isRejoining) { size_t new_idx = results_.size(); - results_.push_back(p1a); + results_.emplace_back(p1a); SetNewOwner(p1a, new_idx); } @@ -861,11 +860,11 @@ namespace Clipper2Lib { if (!op2) return Path64(); Path64 result; - result.push_back(op->pt); + result.emplace_back(op->pt); op2 = op->next; while (op2 != op) { - result.push_back(op2->pt); + result.emplace_back(op2->pt); op2 = op2->next; } return result; @@ -885,7 +884,7 @@ namespace Clipper2Lib { else if (rect_.Contains(path_bounds_)) { // the path must be completely inside rect_ - result.push_back(path); + result.emplace_back(path); continue; } @@ -898,7 +897,7 @@ namespace Clipper2Lib { { Path64 tmp = GetPath(op); if (!tmp.empty()) - result.emplace_back(tmp); + result.emplace_back(std::move(tmp)); } //clean up after every loop @@ -930,7 +929,7 @@ namespace Clipper2Lib { { Path64 tmp = GetPath(op); if (!tmp.empty()) - result.emplace_back(tmp); + result.emplace_back(std::move(tmp)); } results_.clear(); @@ -1015,11 +1014,11 @@ namespace Clipper2Lib { Path64 result; if (!op || op == op->next) return result; op = op->next; // starting at path beginning - result.push_back(op->pt); + result.emplace_back(op->pt); OutPt2 *op2 = op->next; while (op2 != op) { - result.push_back(op2->pt); + result.emplace_back(op2->pt); op2 = op2->next; } return result;