diff options
author | bubnikv <bubnikv@gmail.com> | 2016-09-30 16:23:18 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-09-30 16:23:18 +0300 |
commit | 3a81e6bee420196698e3f1409a8a7318dd35965b (patch) | |
tree | 70574b85f26c77406691b1ed188049fd201911ee /xs/src/libslic3r/ExPolygon.cpp | |
parent | b5e24d3527db0bc9153365b0709787e145aeb982 (diff) |
Bugfix of bottom bridges. If close regions shall be closed by bridges,
these regions are grown to anchor the bridge lines to the bottom surface.
The grown regions may overlap. In that case the regions are now merged
before the bridging direction is calculated for the merged region.
Diffstat (limited to 'xs/src/libslic3r/ExPolygon.cpp')
-rw-r--r-- | xs/src/libslic3r/ExPolygon.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp index 2220772b8..76a48b46a 100644 --- a/xs/src/libslic3r/ExPolygon.cpp +++ b/xs/src/libslic3r/ExPolygon.cpp @@ -4,6 +4,7 @@ #include "Polygon.hpp" #include "Line.hpp" #include "ClipperUtils.hpp" +#include "SVG.hpp" #include "polypartition.h" #include "poly2tri/poly2tri.h" #include <algorithm> @@ -34,6 +35,17 @@ ExPolygon::operator Polygons() const return polygons; } +ExPolygon::operator Polylines() const +{ + Polylines polylines; + polylines.reserve(this->holes.size() + 1); + polylines.push_back((Polyline)this->contour); + for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) { + polylines.push_back((Polyline)*it); + } + return polylines; +} + void ExPolygon::scale(double factor) { @@ -105,6 +117,25 @@ ExPolygon::contains(const Polyline &polyline) const } bool +ExPolygon::contains(const Polylines &polylines) const +{ + #if 0 + BoundingBox bbox = get_extents(polylines); + bbox.merge(get_extents(*this)); + SVG svg("out\\ExPolygon_contains.svg", bbox); + svg.draw(*this); + svg.draw_outline(*this); + svg.draw(polylines, "blue"); + #endif + Polylines pl_out; + diff(polylines, *this, &pl_out); + #if 0 + svg.draw(pl_out, "red"); + #endif + return pl_out.empty(); +} + +bool ExPolygon::contains(const Point &point) const { if (!this->contour.contains(point)) return false; @@ -131,6 +162,16 @@ ExPolygon::has_boundary_point(const Point &point) const return false; } +bool +ExPolygon::overlaps(const ExPolygon &other) const +{ + Polylines pl_out; + intersection((Polylines)other, *this, &pl_out); + if (! pl_out.empty()) + return true; + return ! other.contour.points.empty() && this->contains_b(other.contour.points.front()); +} + void ExPolygon::simplify_p(double tolerance, Polygons* polygons) const { |