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_values.push_back("automatic");
def->enum_values.push_back("autosmall");
def->enum_values.push_back("autoenlarged");
def->enum_values.push_back("enlarged");
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, or anchored if too big"));
def->enum_labels.push_back(L("Anchored"));
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->label = L("Infill extruder");

View File

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

View File

@ -1084,19 +1084,25 @@ namespace Slic3r {
if (!intersect.empty()) {
double area_intersect = 0;
// 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)
area_intersect += poly_inter.area();
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
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))))));
} else {
} else if (layerm->region()->config().infill_dense_algo == dfaAutoNotFull
|| layerm->region()->config().infill_dense_algo == dfaAutomatic) {
//like intersect.empty() but more resilient
if (layerm->region()->config().infill_dense_algo == dfaAutomatic
|| surf.area() > area_intersect * COEFF_SPLIT) {
ExPolygons cover_intersect;
// it will be a dense infill, split the surface if needed
//ExPolygons cover_intersect;
for (ExPolygon& expoly_tocover : intersect) {
ExPolygons temp = dense_fill_fit_to_size(
expoly_tocover,
@ -1107,6 +1113,9 @@ namespace Slic3r {
cover_intersect.insert(cover_intersect.end(), temp.begin(), temp.end());
}
intersect = cover_intersect;
} else {
intersect.clear();
}
}
if (!intersect.empty()) {
ExPolygons sparse_surfaces = diff_ex(sparse_polys, intersect, true);