diff --git a/xs/src/libslic3r/ExPolygonCollection.cpp b/xs/src/libslic3r/ExPolygonCollection.cpp index 9de1cb786..ec27505a5 100644 --- a/xs/src/libslic3r/ExPolygonCollection.cpp +++ b/xs/src/libslic3r/ExPolygonCollection.cpp @@ -140,5 +140,12 @@ ExPolygonCollection::append(const ExPolygon &expp) { this->expolygons.push_back(expp); } +bool +ExPolygonCollection::contains(const Point &point) const { + for (const auto& poly : this->expolygons) { + if (poly.contour.contains(point)) return true; + } + return false; +} } diff --git a/xs/src/libslic3r/ExPolygonCollection.hpp b/xs/src/libslic3r/ExPolygonCollection.hpp index b11e41ecd..1acd080a2 100644 --- a/xs/src/libslic3r/ExPolygonCollection.hpp +++ b/xs/src/libslic3r/ExPolygonCollection.hpp @@ -36,6 +36,11 @@ class ExPolygonCollection Polygons holes() const; void append(const ExPolygons &expolygons); void append(const ExPolygon &expolygons); + + /// Convenience function to iterate through all of the owned + /// ExPolygons and check if at least one contains the point. + bool contains(const Point &point) const; + }; inline ExPolygonCollection&