Skip to content

Commit

Permalink
fix perimeter being cut (also for arachne)
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jul 13, 2023
2 parents 9898398 + d5c44b1 commit a0f34b1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2226,9 +2226,15 @@ ExtrusionPaths PerimeterGenerator::create_overhangs(const ClipperLib_Z::Path& ar
if (paths.size() > 2) {
double min_length = this->perimeter_flow.scaled_width() * 2;
double ok_length = this->perimeter_flow.scaled_width() * 20;

#ifdef _DEBUG
for (int i = 1; i < paths.size(); i++) {
assert(paths[i - 1].last_point() == paths[i].first_point());
}
#endif
foreach(paths, [min_length, ok_length](ExtrusionPath& prev, ExtrusionPath& curr, ExtrusionPath& next) {
assert(prev.last_point() == curr.first_point());
if (curr.length() < min_length) {
// if too small, merge it with prev or next, whatever is best.
float diff_height = std::abs(prev.height - curr.height) - std::abs(next.height - curr.height);
//have to choose the rigth path
if (diff_height < 0 || (diff_height == 0 && prev.length() > next.length())) {
Expand All @@ -2243,16 +2249,25 @@ ExtrusionPaths PerimeterGenerator::create_overhangs(const ClipperLib_Z::Path& ar
curr.polyline.append(next.polyline);
next.polyline.swap(curr.polyline);
}
assert(prev.last_point() == next.first_point());
return true;
} else if (((int)curr.height) % 2 == 1 && curr.length() > ok_length) {
// not too small, and we are still undecided (%2==1) of the type of this section
// so choose to add it to the prev, or next, or keep it in limbo until another foreach.
curr.height++;
if (prev.height == curr.height) {
//merge to prev
prev.polyline.append(curr.polyline);
return true;
} else if (next.height == curr.height) {
//merge to next
curr.polyline.append(next.polyline);
next.polyline.swap(curr.polyline);
return true;
} else {
//keep it in limbo
return false;
}
return true;
}
return false;
});
Expand Down

0 comments on commit a0f34b1

Please sign in to comment.