Minor improvement of the special case of extra perimeters path ordering

This commit is contained in:
PavelMikus 2023-03-30 16:56:47 +02:00
parent f95810bee4
commit d3037d325a
2 changed files with 13 additions and 1 deletions

View File

@ -1033,6 +1033,18 @@ std::tuple<std::vector<ExtrusionPaths>, Polygons> generate_extra_perimeters_over
};
if (!first_overhang_is_closed_and_anchored) {
std::reverse(overhang_region.begin(), overhang_region.end());
} else {
size_t min_dist_idx = 0;
double min_dist = std::numeric_limits<double>::max();
for (size_t i = 0; i < overhang_region.front().polyline.size(); i++) {
Point p = overhang_region.front().polyline[i];
if (double d = lower_layer_aabb_tree.distance_from_lines<true>(p) < min_dist) {
min_dist = d;
min_dist_idx = i;
}
}
std::rotate(overhang_region.front().polyline.begin(), overhang_region.front().polyline.begin() + min_dist_idx,
overhang_region.front().polyline.end());
}
auto first_unanchored = std::stable_partition(overhang_region.begin(), overhang_region.end(), is_anchored);
int index_of_first_unanchored = first_unanchored - overhang_region.begin();

View File

@ -31,7 +31,7 @@
#include "I18N.hpp"
#include <libnest2d/tools/benchmark.h>
#include "format.hpp"
namespace Slic3r {