diff --git a/xs/src/libslic3r/BoundingBox.cpp b/xs/src/libslic3r/BoundingBox.cpp index 2b3f00df18..bffe1dbfb1 100644 --- a/xs/src/libslic3r/BoundingBox.cpp +++ b/xs/src/libslic3r/BoundingBox.cpp @@ -271,7 +271,8 @@ template bool BoundingBoxBase::contains(const Pointf &point) const; template bool BoundingBoxBase::overlap(const BoundingBoxBase &other) const { - return this->contains(other.min) || other.contains(this->min); + return ! (this->max.x < other.min.x || this->min.x > other.max.x || + this->max.y < other.min.y || this->min.y > other.max.y); } template bool BoundingBoxBase::overlap(const BoundingBoxBase &point) const; template bool BoundingBoxBase::overlap(const BoundingBoxBase &point) const; diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp index 76a48b46a5..4861a08fde 100644 --- a/xs/src/libslic3r/ExPolygon.cpp +++ b/xs/src/libslic3r/ExPolygon.cpp @@ -165,8 +165,22 @@ ExPolygon::has_boundary_point(const Point &point) const bool ExPolygon::overlaps(const ExPolygon &other) const { + #if 0 + BoundingBox bbox = get_extents(other); + bbox.merge(get_extents(*this)); + static int iRun = 0; + char path[2048]; + sprintf(path, "out\\ExPolygon_overlaps-%d.svg", iRun ++); + SVG svg(path, bbox); + svg.draw(*this); + svg.draw_outline(*this); + svg.draw_outline(other, "blue"); + #endif Polylines pl_out; intersection((Polylines)other, *this, &pl_out); + #if 0 + svg.draw(pl_out, "red"); + #endif if (! pl_out.empty()) return true; return ! other.contour.points.empty() && this->contains_b(other.contour.points.front()); diff --git a/xs/src/libslic3r/ExPolygon.hpp b/xs/src/libslic3r/ExPolygon.hpp index f283822da3..ef3c153dcb 100644 --- a/xs/src/libslic3r/ExPolygon.hpp +++ b/xs/src/libslic3r/ExPolygon.hpp @@ -38,7 +38,7 @@ class ExPolygon // Does this expolygon overlap another expolygon? // Either the ExPolygons intersect, or one is fully inside the other, // and it is not inside a hole of the other expolygon. - bool overlap(const ExPolygon &other) const; + bool overlaps(const ExPolygon &other) const; void simplify_p(double tolerance, Polygons* polygons) const; Polygons simplify_p(double tolerance) const;