Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/CuraEngine.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjspijker <j.spijker@ultimaker.com>2022-11-03 18:18:06 +0300
committerjspijker <j.spijker@ultimaker.com>2022-11-03 18:18:06 +0300
commit3591deb29f8e33b073b099fbb649d4ebb6b56c91 (patch)
tree30288a9b9f8a8a08457ed164543200881d877d20
parentbb39958d4160b95b7c60ac22b507fcbeaffc6fc4 (diff)
Check if a polygon is completely inside another polygon
Contribute to CURA-9775
-rw-r--r--include/utils/polygon.h17
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