ENH: reorder print area to reduce travel time

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: I8fd5c505a42ae850d91c061d4df08257fb03c8c8
This commit is contained in:
qing.zhang 2023-05-29 19:37:07 +08:00 committed by Lane.Wei
parent 10838680dd
commit 5ae0adde16
3 changed files with 18 additions and 1 deletions

View file

@ -835,7 +835,13 @@ void PerimeterGenerator::process_classic()
// BBS: don't simplify too much which influence arc fitting when export gcode if arc_fitting is enabled // BBS: don't simplify too much which influence arc fitting when export gcode if arc_fitting is enabled
double surface_simplify_resolution = (print_config->enable_arc_fitting && this->config->fuzzy_skin == FuzzySkinType::None) ? 0.2 * m_scaled_resolution : m_scaled_resolution; double surface_simplify_resolution = (print_config->enable_arc_fitting && this->config->fuzzy_skin == FuzzySkinType::None) ? 0.2 * m_scaled_resolution : m_scaled_resolution;
for (const Surface &surface : this->slices->surfaces) { //BBS: reorder the surface to reduce the travel time
ExPolygons surface_exp;
for (const Surface &surface : this->slices->surfaces)
surface_exp.push_back(surface.expolygon);
std::vector<size_t> surface_order = chain_expolygons(surface_exp);
for (size_t order_idx = 0; order_idx < surface_order.size(); order_idx++) {
const Surface &surface = this->slices->surfaces[surface_order[order_idx]];
// detect how many perimeters must be generated for this island // detect how many perimeters must be generated for this island
int loop_number = this->config->wall_loops + surface.extra_perimeters - 1; // 0-indexed loops int loop_number = this->config->wall_loops + surface.extra_perimeters - 1; // 0-indexed loops
//BBS: set the topmost and bottom most layer to be one wall //BBS: set the topmost and bottom most layer to be one wall

View file

@ -1057,6 +1057,16 @@ void chain_and_reorder_extrusion_paths(std::vector<ExtrusionPath> &extrusion_pat
reorder_extrusion_paths(extrusion_paths, chain_extrusion_paths(extrusion_paths, start_near)); reorder_extrusion_paths(extrusion_paths, chain_extrusion_paths(extrusion_paths, start_near));
} }
std::vector<size_t> chain_expolygons(const ExPolygons &input_exploy) {
Points points;
for (const ExPolygon &exploy : input_exploy) {
BoundingBox bbox;
bbox = get_extents(exploy);
points.push_back(bbox.center());
}
return chain_points(points);
}
std::vector<size_t> chain_points(const Points &points, Point *start_near) std::vector<size_t> chain_points(const Points &points, Point *start_near)
{ {
auto segment_end_point = [&points](size_t idx, bool /* first_point */) -> const Point& { return points[idx]; }; auto segment_end_point = [&points](size_t idx, bool /* first_point */) -> const Point& { return points[idx]; };

View file

@ -13,6 +13,7 @@ namespace ClipperLib { class PolyNode; }
namespace Slic3r { namespace Slic3r {
std::vector<size_t> chain_points(const Points &points, Point *start_near = nullptr); std::vector<size_t> chain_points(const Points &points, Point *start_near = nullptr);
std::vector<size_t> chain_expolygons(const ExPolygons &input_exploy);
std::vector<std::pair<size_t, bool>> chain_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const Point *start_near = nullptr); std::vector<std::pair<size_t, bool>> chain_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const Point *start_near = nullptr);
void reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const std::vector<std::pair<size_t, bool>> &chain); void reorder_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const std::vector<std::pair<size_t, bool>> &chain);