Fix small top/bottom solid infill filtering (#6794)

* Fix issue that small sparse gaps are not filtered out correctly

* Fix code order
This commit is contained in:
Noisyfox 2024-09-19 00:02:16 +08:00 committed by GitHub
parent 8aac37de6a
commit 47965b02d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -523,24 +523,6 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
#endif #endif
} }
// turn too small internal regions into solid regions according to the user setting
if (!this->layer()->object()->print()->config().spiral_mode && this->region().config().sparse_infill_density.value > 0) {
// scaling an area requires two calls!
double min_area = scale_(scale_(this->region().config().minimum_sparse_infill_area.value));
ExPolygons small_regions{};
sparse.erase(std::remove_if(sparse.begin(), sparse.end(), [min_area, &small_regions](ExPolygon& ex_polygon) {
if (ex_polygon.area() <= min_area) {
small_regions.push_back(ex_polygon);
return true;
}
return false;
}), sparse.end());
if (!small_regions.empty()) {
expansion_zones[0].expolygons = union_ex(expansion_zones[0].expolygons, small_regions);
}
}
this->fill_surfaces.remove_types({stTop}); this->fill_surfaces.remove_types({stTop});
{ {
Surface top_templ(stTop, {}); Surface top_templ(stTop, {});
@ -556,6 +538,24 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
expansion_zones.at(0).parameters = RegionExpansionParameters::build(expansion_top, expansion_step, max_nr_expansion_steps); expansion_zones.at(0).parameters = RegionExpansionParameters::build(expansion_top, expansion_step, max_nr_expansion_steps);
Surfaces tops = expand_merge_surfaces(this->fill_surfaces.surfaces, stTop, expansion_zones, closing_radius); Surfaces tops = expand_merge_surfaces(this->fill_surfaces.surfaces, stTop, expansion_zones, closing_radius);
// turn too small internal regions into solid regions according to the user setting
if (!this->layer()->object()->print()->config().spiral_mode && this->region().config().sparse_infill_density.value > 0) {
// scaling an area requires two calls!
double min_area = scale_(scale_(this->region().config().minimum_sparse_infill_area.value));
ExPolygons small_regions{};
expansion_zones[1].expolygons.erase(std::remove_if(expansion_zones[1].expolygons.begin(), expansion_zones[1].expolygons.end(), [min_area, &small_regions](ExPolygon& ex_polygon) {
if (ex_polygon.area() <= min_area) {
small_regions.push_back(ex_polygon);
return true;
}
return false;
}), expansion_zones[1].expolygons.end());
if (!small_regions.empty()) {
expansion_zones[0].expolygons = union_ex(expansion_zones[0].expolygons, small_regions);
}
}
// this->fill_surfaces.remove_types({ stBottomBridge, stBottom, stTop, stInternal, stInternalSolid }); // this->fill_surfaces.remove_types({ stBottomBridge, stBottom, stTop, stInternal, stInternalSolid });
this->fill_surfaces.clear(); this->fill_surfaces.clear();
unsigned zones_expolygons_count = 0; unsigned zones_expolygons_count = 0;