Skip to content

Commit

Permalink
Fix slices_to_fill_surfaces_clipped:
Browse files Browse the repository at this point in the history
 * fix bad 2.4 merge
 * more robust for simplified slices
#2807
  • Loading branch information
supermerill committed May 18, 2022
1 parent 1abc2e6 commit 53d940c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/libslic3r/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class LayerRegion
Flow flow(FlowRole role, double layer_height) const;
Flow bridging_flow(FlowRole role) const;

void slices_to_fill_surfaces_clipped();
void slices_to_fill_surfaces_clipped(coord_t opening_offset);
void prepare_fill_surfaces();
void make_perimeters(const SurfaceCollection& slices, SurfaceCollection* fill_surfaces);
void make_milling_post_process(const SurfaceCollection& slices);
Expand Down
35 changes: 7 additions & 28 deletions src/libslic3r/LayerRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Flow LayerRegion::bridging_flow(FlowRole role) const
}

// Fill in layerm->fill_surfaces by trimming the layerm->slices by the cummulative layerm->fill_surfaces.
void LayerRegion::slices_to_fill_surfaces_clipped()
void LayerRegion::slices_to_fill_surfaces_clipped(coord_t opening_offset)
{
//if (this->region()->config().no_perimeter_full_bridge) return;
// Note: this method should be idempotent, but fill_surfaces gets modified
Expand All @@ -68,33 +68,12 @@ void LayerRegion::slices_to_fill_surfaces_clipped()
// Trim surfaces by the fill_boundaries.
this->fill_surfaces.surfaces.clear();
for (auto const& entry : polygons_by_surface) {
if (!entry.second.empty()) {
//if (entry.first & stModBridge == stModBridge && this->region()->config().no_perimeter_full_bridge)
// this->fill_surfaces.append(entry.second, entry.first);
//else
this->fill_surfaces.append(intersection_ex(entry.second, this->fill_expolygons), entry.first);
}
//if (this->region()->config().no_perimeter_full_bridge) return;
// Note: this method should be idempotent, but fill_surfaces gets modified
// in place. However we're now only using its boundaries (which are invariant)
// so we're safe. This guarantees idempotence of prepare_infill() also in case
// that combine_infill() turns some fill_surface into VOID surfaces.
// Polygons fill_boundaries = to_polygons(std::move(this->fill_surfaces));
Polygons fill_boundaries = to_polygons(this->fill_expolygons);
// Collect polygons per surface type.
std::map<SurfaceType, Polygons> polygons_by_surface;
for (const Surface& surface : this->slices().surfaces) {
polygons_append(polygons_by_surface[surface.surface_type], surface.expolygon);
}
// Trim surfaces by the fill_boundaries.
this->fill_surfaces.surfaces.clear();
for (auto const& entry : polygons_by_surface) {
if (!entry.second.empty())
//if (entry.first & stModBridge == stModBridge && this->region()->config().no_perimeter_full_bridge)
// this->fill_surfaces.append(entry.second, entry.first);
//else
this->fill_surfaces.append(intersection_ex(entry.second, fill_boundaries), entry.first);
}
if (!entry.second.empty())
for (ExPolygon& expoly_to_test : intersection_ex(entry.second, this->fill_expolygons)) {
if (!opening_ex({ expoly_to_test }, opening_offset).empty()) {
this->fill_surfaces.append({ expoly_to_test }, entry.first);
}
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,25 +1234,25 @@ void PerimeterGenerator::process()
// simplify infill contours according to resolution
Polygons not_filled_p;
for (ExPolygon& ex : last_no_gaps)
ex.simplify_p(scale_t(print_config->resolution_internal), &not_filled_p);
ex.simplify_p(scale_t(std::max(this->print_config->resolution.value, print_config->resolution_internal/4)), &not_filled_p);
ExPolygons not_filled_exp = union_ex(not_filled_p);
// collapse too narrow infill areas
coord_t min_perimeter_infill_spacing = (coord_t)(solid_infill_spacing * (1. - INSET_OVERLAP_TOLERANCE));
ExPolygons infill_exp;
//special branch if gap : don't inset away from gaps!
if (gap_srf.empty())
if (gap_srf.empty()) {
infill_exp = offset2_ex(not_filled_exp,
double(-inset - min_perimeter_infill_spacing / 2 + infill_peri_overlap - infill_gap),
double(min_perimeter_infill_spacing / 2));
else {
} else {
//store the infill_exp but not offseted, it will be used as a clip to remove the gapfill portion
const ExPolygons infill_exp_no_gap = offset2_ex(not_filled_exp,
double(-inset - min_perimeter_infill_spacing / 2 + infill_peri_overlap - infill_gap),
double(inset + min_perimeter_infill_spacing / 2 - infill_peri_overlap + infill_gap));
//redo the same as not_filled_exp but with last instead of last_no_gaps
not_filled_p.clear();
for (ExPolygon& ex : last)
ex.simplify_p(scale_t(print_config->resolution_internal), &not_filled_p);
ex.simplify_p(scale_t(std::max(this->print_config->resolution.value, print_config->resolution_internal/4)), &not_filled_p);
not_filled_exp = union_ex(not_filled_p);
infill_exp = offset2_ex(not_filled_exp,
double(-inset - min_perimeter_infill_spacing / 2 + infill_peri_overlap - infill_gap),
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4099,7 +4099,7 @@ void PrintConfigDef::init_fff_params()
def->min = 0.001;
def->precision = 8;
def->mode = comExpert | comSuSi;
def->set_default_value(new ConfigOptionFloat(0.2));
def->set_default_value(new ConfigOptionFloat(0.1));

def = this->add("retract_before_travel", coFloats);
def->label = L("Minimum travel after retraction");
Expand Down
5 changes: 4 additions & 1 deletion src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,10 @@ bool PrintObject::invalidate_state_by_config_options(
for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++idx_layer) {
m_print->throw_if_canceled();
LayerRegion* layerm = m_layers[idx_layer]->get_region(region_id);
layerm->slices_to_fill_surfaces_clipped();
layerm->slices_to_fill_surfaces_clipped(
std::max(SCALED_EPSILON * 2,
std::max(scale_t(m_print->config().resolution) / 4,
scale_t(m_print->config().resolution_internal) / 8)));
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
layerm->export_region_fill_surfaces_to_svg_debug("1_detect_surfaces_type-final");
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
Expand Down

0 comments on commit 53d940c

Please sign in to comment.