diff options
author | jspijker <j.spijker@ultimaker.com> | 2022-11-03 18:18:06 +0300 |
---|---|---|
committer | jspijker <j.spijker@ultimaker.com> | 2022-11-03 18:18:06 +0300 |
commit | 3591deb29f8e33b073b099fbb649d4ebb6b56c91 (patch) | |
tree | 30288a9b9f8a8a08457ed164543200881d877d20 | |
parent | bb39958d4160b95b7c60ac22b507fcbeaffc6fc4 (diff) |
Check if a polygon is completely inside another polygon
Contribute to CURA-9775
-rw-r--r-- | include/utils/polygon.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/include/utils/polygon.h b/include/utils/polygon.h index 4f612eeb1..65323086f 100644 --- a/include/utils/polygon.h +++ b/include/utils/polygon.h @@ -1,5 +1,5 @@ -//Copyright (c) 2022 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2022 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher #ifndef UTILS_POLYGON_H #define UTILS_POLYGON_H @@ -299,6 +299,19 @@ public: return res == 1; } + bool inside(const auto& polygon) const + { + for (const auto& point : *path) + { + const auto res = ClipperLib::PointInPolygon(point, *polygon.path); + if (res < 1) + { + return false; + } + } + return true; + } + /*! * Smooth out small perpendicular segments and store the result in \p result. * Smoothing is performed by removing the inner most vertex of a line segment smaller than \p remove_length |