Revamp of implementation of the avoid crossing perimeters algorithm.

The strategy for the avoid crossing perimeters algorithm has been redesigned. But external travels (travel between objects or supports) have not been solved yet. For these travels is used a direct path between two points.
Much of the code has been reworked, which leads to significant speedup compared to the previous implementation.
Also, several potential bugs have been fixed.
This commit is contained in:
Lukáš Hejl 2020-11-29 13:58:36 +01:00
parent 606db666fc
commit 55c282d85d
3 changed files with 771 additions and 219 deletions

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,17 @@ public:
Polyline travel_to(const GCode& gcodegen, const Point& point, bool* could_be_wipe_disabled); Polyline travel_to(const GCode& gcodegen, const Point& point, bool* could_be_wipe_disabled);
struct Boundary {
// Collection of boundaries used for detection of crossing perimeters for travels
Polygons boundaries;
// Bounding box of boundaries
BoundingBoxf bbox;
// Precomputed distances of all points in boundaries
std::vector<std::vector<float>> boundaries_params;
// Used for detection of intersection between line and any polygon from boundaries
EdgeGrid::Grid grid;
};
private: private:
bool m_use_external_mp { false }; bool m_use_external_mp { false };
// just for the next travel move // just for the next travel move
@ -40,18 +51,14 @@ private:
// we enable it by default for the first travel move in print // we enable it by default for the first travel move in print
bool m_disabled_once { true }; bool m_disabled_once { true };
// Slice of layer with elephant foot compensation // Used for detection of line or polyline is inside of any polygon.
ExPolygons m_slice; EdgeGrid::Grid m_grid_lslice;
// Collection of boundaries used for detection of crossing perimetrs for travels inside object // Store all needed data for travels inside object
Polygons m_boundaries; Boundary m_internal;
// Collection of boundaries used for detection of crossing perimetrs for travels outside object #if 0
Polygons m_boundaries_external; // Store all needed data for travels outside object
// Bounding box of m_boundaries Boundary m_external;
BoundingBoxf m_bbox; #endif
// Bounding box of m_boundaries_external
BoundingBoxf m_bbox_external;
EdgeGrid::Grid m_grid;
EdgeGrid::Grid m_grid_external;
}; };
} // namespace Slic3r } // namespace Slic3r

View File

@ -124,7 +124,7 @@ inline void append(std::vector<T>& dest, std::vector<T>&& src)
if (dest.empty()) if (dest.empty())
dest = std::move(src); dest = std::move(src);
else { else {
dest.resize(dest.size() + src.size()); dest.reserve(dest.size() + src.size());
std::move(std::begin(src), std::end(src), std::back_inserter(dest)); std::move(std::begin(src), std::end(src), std::back_inserter(dest));
} }
src.clear(); src.clear();