diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2014-10-15 02:59:26 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2014-10-15 02:59:26 +0400 |
commit | 6b8f03ff1c8a83be88adf61486a6b47e4f3958b3 (patch) | |
tree | bab4582c3eb05252e6c14ca51036012db106ad64 /xs/src/libslic3r/MotionPlanner.cpp | |
parent | 39b41fda1279bf397eaf68b7a3d681eb515b23bd (diff) |
Bugfix: crash in some circumstances when avoid_crossing_perimeters is enabled. #2266
Diffstat (limited to 'xs/src/libslic3r/MotionPlanner.cpp')
-rw-r--r-- | xs/src/libslic3r/MotionPlanner.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/xs/src/libslic3r/MotionPlanner.cpp b/xs/src/libslic3r/MotionPlanner.cpp index b562a2832..dd626cda7 100644 --- a/xs/src/libslic3r/MotionPlanner.cpp +++ b/xs/src/libslic3r/MotionPlanner.cpp @@ -18,10 +18,17 @@ MotionPlanner::~MotionPlanner() delete *graph; } +size_t +MotionPlanner::islands_count() const +{ + return this->islands.size(); +} + void MotionPlanner::initialize() { if (this->initialized) return; + if (this->islands.empty()) return; // prevent initialization of empty BoundingBox ExPolygons expp; for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) { @@ -70,6 +77,12 @@ MotionPlanner::shortest_path(const Point &from, const Point &to, Polyline* polyl { if (!this->initialized) this->initialize(); + if (this->islands.empty()) { + polyline->points.push_back(from); + polyline->points.push_back(to); + return; + } + // Are both points in the same island? int island_idx = -1; for (ExPolygons::const_iterator island = this->islands.begin(); island != this->islands.end(); ++island) { |