Automatic dense infill falls back to the Enlarge algorithm in a new option (now new default)

This commit is contained in:
remi durand 2021-02-22 17:29:39 +01:00
parent d25f1bffa1
commit 605a4323e6
3 changed files with 28 additions and 16 deletions

View File

@ -2048,12 +2048,14 @@ void PrintConfigDef::init_fff_params()
def->enum_keys_map = &ConfigOptionEnum<DenseInfillAlgo>::get_enum_values(); def->enum_keys_map = &ConfigOptionEnum<DenseInfillAlgo>::get_enum_values();
def->enum_values.push_back("automatic"); def->enum_values.push_back("automatic");
def->enum_values.push_back("autosmall"); def->enum_values.push_back("autosmall");
def->enum_values.push_back("autoenlarged");
def->enum_values.push_back("enlarged"); def->enum_values.push_back("enlarged");
def->enum_labels.push_back(L("Automatic")); def->enum_labels.push_back(L("Automatic"));
def->enum_labels.push_back(L("Automatic, only for small areas")); def->enum_labels.push_back(L("Automatic, only for small areas"));
def->enum_labels.push_back(L("Automatic, or anchored if too big"));
def->enum_labels.push_back(L("Anchored")); def->enum_labels.push_back(L("Anchored"));
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<DenseInfillAlgo>(dfaAutoNotFull)); def->set_default_value(new ConfigOptionEnum<DenseInfillAlgo>(dfaAutoOrEnlarged));
def = this->add("infill_extruder", coInt); def = this->add("infill_extruder", coInt);
def->label = L("Infill extruder"); def->label = L("Infill extruder");

View File

@ -114,7 +114,7 @@ enum SLAMaterial {
slamHeatResistant, slamHeatResistant,
}; };
enum DenseInfillAlgo { enum DenseInfillAlgo {
dfaAutomatic, dfaAutoNotFull, dfaEnlarged, dfaAutomatic, dfaAutoNotFull, dfaAutoOrEnlarged , dfaEnlarged,
}; };
enum NoPerimeterUnsupportedAlgo { enum NoPerimeterUnsupportedAlgo {
@ -298,6 +298,7 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<DenseInfillAlgo>:
static const t_config_enum_values keys_map = { static const t_config_enum_values keys_map = {
{ "automatic", dfaAutomatic }, { "automatic", dfaAutomatic },
{ "autosmall", dfaAutoNotFull }, { "autosmall", dfaAutoNotFull },
{ "autoenlarged", dfaAutoOrEnlarged },
{ "enlarged", dfaEnlarged } { "enlarged", dfaEnlarged }
}; };
return keys_map; return keys_map;

View File

@ -1084,29 +1084,38 @@ namespace Slic3r {
if (!intersect.empty()) { if (!intersect.empty()) {
double area_intersect = 0; double area_intersect = 0;
// calculate area to decide if area is small enough for autofill // calculate area to decide if area is small enough for autofill
if (layerm->region()->config().infill_dense_algo == dfaAutoNotFull) if (layerm->region()->config().infill_dense_algo == dfaAutoNotFull || layerm->region()->config().infill_dense_algo == dfaAutoOrEnlarged)
for (ExPolygon poly_inter : intersect) for (ExPolygon poly_inter : intersect)
area_intersect += poly_inter.area(); area_intersect += poly_inter.area();
if (layerm->region()->config().infill_dense_algo == dfaEnlarged if (layerm->region()->config().infill_dense_algo == dfaEnlarged
|| (layerm->region()->config().infill_dense_algo == dfaAutoNotFull && surf.area() <= area_intersect * COEFF_SPLIT)) { || (layerm->region()->config().infill_dense_algo == dfaAutoOrEnlarged && surf.area() <= area_intersect * COEFF_SPLIT)) {
//expand the area a bit //expand the area a bit
intersect = offset_ex(intersect, double(scale_(layerm->region()->config().external_infill_margin.get_abs_value( intersect = offset_ex(intersect, double(scale_(layerm->region()->config().external_infill_margin.get_abs_value(
region->config().perimeters == 0 ? 0 : (layerm->flow(frExternalPerimeter).width + layerm->flow(frPerimeter).spacing() * (region->config().perimeters - 1)))))); region->config().perimeters == 0 ? 0 : (layerm->flow(frExternalPerimeter).width + layerm->flow(frPerimeter).spacing() * (region->config().perimeters - 1))))));
} else { } else if (layerm->region()->config().infill_dense_algo == dfaAutoNotFull
ExPolygons cover_intersect; || layerm->region()->config().infill_dense_algo == dfaAutomatic) {
// it will be a dense infill, split the surface if needed //like intersect.empty() but more resilient
for (ExPolygon& expoly_tocover : intersect) { if (layerm->region()->config().infill_dense_algo == dfaAutomatic
ExPolygons temp = dense_fill_fit_to_size( || surf.area() > area_intersect * COEFF_SPLIT) {
expoly_tocover, ExPolygons cover_intersect;
diff_ex(offset_ex(layerm->fill_no_overlap_expolygons, double(layerm->flow(frInfill).scaled_width())), offset_ex(layerm->fill_no_overlap_expolygons, double(-layerm->flow(frInfill).scaled_width()))),
surf.expolygon, // it will be a dense infill, split the surface if needed
4 * layerm->flow(frInfill).scaled_width(), //ExPolygons cover_intersect;
0.01f); for (ExPolygon& expoly_tocover : intersect) {
cover_intersect.insert(cover_intersect.end(), temp.begin(), temp.end()); ExPolygons temp = dense_fill_fit_to_size(
expoly_tocover,
diff_ex(offset_ex(layerm->fill_no_overlap_expolygons, double(layerm->flow(frInfill).scaled_width())), offset_ex(layerm->fill_no_overlap_expolygons, double(-layerm->flow(frInfill).scaled_width()))),
surf.expolygon,
4 * layerm->flow(frInfill).scaled_width(),
0.01f);
cover_intersect.insert(cover_intersect.end(), temp.begin(), temp.end());
}
intersect = cover_intersect;
} else {
intersect.clear();
} }
intersect = cover_intersect;
} }
if (!intersect.empty()) { if (!intersect.empty()) {
ExPolygons sparse_surfaces = diff_ex(sparse_polys, intersect, true); ExPolygons sparse_surfaces = diff_ex(sparse_polys, intersect, true);