Skip to content

Commit

Permalink
Fix perimeter artifact & brim resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Feb 21, 2022
1 parent d3503f6 commit 94826b6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/libslic3r/Brim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ void make_brim(const Print& print, const Flow& flow, const PrintObjectPtrs& obje
coordf_t scaled_resolution = scale_d(brim_config.get_computed_value("resolution_internal"));
ExPolygons unbrimmable_areas;
for (ExPolygon& expoly : islands)
for (ExPolygon& expoly : expoly.simplify(scaled_resolution))
for (ExPolygon& expoly : expoly.simplify(scaled_resolution/10))
unbrimmable_areas.emplace_back(std::move(expoly));
islands = union_safety_offset_ex(unbrimmable_areas);
unbrimmable_areas = islands;
Expand Down Expand Up @@ -1048,7 +1048,7 @@ void make_brim_ears(const Print& print, const Flow& flow, const PrintObjectPtrs&

print.throw_if_canceled();

coordf_t scaled_resolution = scale_d(brim_config.get_computed_value("resolution_internal"));
const coordf_t scaled_resolution = scale_d(brim_config.get_computed_value("resolution_internal"));
if (brim_config.brim_ears_pattern.value == InfillPattern::ipConcentric) {

//create loops (same as standard brim)
Expand All @@ -1060,7 +1060,7 @@ void make_brim_ears(const Print& print, const Flow& flow, const PrintObjectPtrs&
for (ExPolygon& expoly : islands) {
Polygon poly = expoly.contour;
poly.points.push_back(poly.points.front());
Points p = MultiPoint::_douglas_peucker(poly.points, scaled_resolution);
Points p = MultiPoint::_douglas_peucker(poly.points, scaled_resolution/10);
p.pop_back();
poly.points = std::move(p);
loops.push_back(poly);
Expand Down Expand Up @@ -1195,7 +1195,7 @@ void make_brim_interior(const Print& print, const Flow& flow, const PrintObjectP
brimmable_areas = diff_ex(brimmable_areas, unbrimmable_areas, ApplySafetyOffset::Yes);

//now get all holes, use them to create loops
coordf_t scaled_resolution = scale_d(brim_config.get_computed_value("resolution_internal"));
const coordf_t scaled_resolution = scale_d(brim_config.get_computed_value("resolution_internal"));
std::vector<std::vector<BrimLoop>> loops;
for (size_t i = 0; i < num_loops; ++i) {
print.throw_if_canceled();
Expand All @@ -1205,7 +1205,7 @@ void make_brim_interior(const Print& print, const Flow& flow, const PrintObjectP
Polygons temp = offset(poly, double(-flow.scaled_spacing()), jtSquare);
for (Polygon& poly : temp) {
poly.points.push_back(poly.points.front());
Points p = MultiPoint::_douglas_peucker(poly.points, scaled_resolution);
Points p = MultiPoint::_douglas_peucker(poly.points, scaled_resolution/10);
p.pop_back();
poly.points = std::move(p);
}
Expand Down
21 changes: 17 additions & 4 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ void PerimeterGenerator::process()
}

// allow this perimeter to overlap itself?
const float thin_perimeter = perimeter_idx == 0 ? this->config->thin_perimeters.get_abs_value(1) : this->config->thin_perimeters_all.get_abs_value(1);
float thin_perimeter = perimeter_idx == 0 ? this->config->thin_perimeters.get_abs_value(1) : this->config->thin_perimeters_all.get_abs_value(1);
if (thin_perimeter < 0.02) // can create artifacts
thin_perimeter = 0;

// Calculate next onion shell of perimeters.
//this variable stored the next onion
Expand All @@ -530,20 +532,31 @@ void PerimeterGenerator::process()
-(float)(ext_perimeter_width / 2),
ClipperLib::JoinType::jtMiter,
3);
else if (thin_perimeter > 0.01)
else if (thin_perimeter > 0.01) {
next_onion = offset2_ex(
last,
-(float)(ext_perimeter_width / 2 + (1 - thin_perimeter) * ext_perimeter_spacing / 2 - 1),
+(float)((1 - thin_perimeter) * ext_perimeter_spacing / 2 - 1),
ClipperLib::JoinType::jtMiter,
3);
else
} else {
next_onion = offset2_ex(
last,
-(float)(ext_perimeter_width / 2 + ext_perimeter_spacing / 2 - 1),
+(float)(ext_perimeter_spacing / 2 - 1),
+(float)(ext_perimeter_spacing / 2 + 1),
ClipperLib::JoinType::jtMiter,
3);
}
if (thin_perimeter < 0.7) {
//offset2_ex can create artifacts, if too big. see superslicer#2428
next_onion = intersection_ex(next_onion,
offset_ex(
last,
-(float)(ext_perimeter_width / 2),
ClipperLib::JoinType::jtMiter,
3));
}


// look for thin walls
if (this->config->thin_walls) {
Expand Down

0 comments on commit 94826b6

Please sign in to comment.