add Detect narrow internal solid infill

This commit is contained in:
Wang YB
2023-11-11 13:26:38 +08:00
parent 01d319ed8a
commit ea99e07679
5 changed files with 62 additions and 7 deletions

View File

@@ -17,7 +17,8 @@
#include "FillConcentric.hpp"
#include "FillEnsuring.hpp"
#include "Polygon.hpp"
//w11
#define NARROW_INFILL_AREA_THRESHOLD 3
namespace Slic3r {
//static constexpr const float NarrowInfillAreaThresholdMM = 3.f;
@@ -112,7 +113,15 @@ struct SurfaceFill {
ExPolygons expolygons;
SurfaceFillParams params;
};
//w11
static bool is_narrow_infill_area(const ExPolygon &expolygon)
{
ExPolygons offsets = offset_ex(expolygon, -scale_(NARROW_INFILL_AREA_THRESHOLD));
if (offsets.empty())
return true;
return false;
}
static inline bool fill_type_monotonic(InfillPattern pattern)
{
return pattern == ipMonotonic || pattern == ipMonotonicLines;
@@ -313,7 +322,43 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
fill.params.pattern = ipEnsuring;
}
}
//w11
if (layer.object()->config().detect_narrow_internal_solid_infill) {
size_t surface_fills_size = surface_fills.size();
for (size_t i = 0; i < surface_fills_size; i++) {
if (surface_fills[i].surface.surface_type != stInternalSolid)
continue;
size_t expolygons_size = surface_fills[i].expolygons.size();
std::vector<size_t> narrow_expolygons_index;
narrow_expolygons_index.reserve(expolygons_size);
for (size_t j = 0; j < expolygons_size; j++)
if (is_narrow_infill_area(surface_fills[i].expolygons[j]))
narrow_expolygons_index.push_back(j);
if (narrow_expolygons_index.size() == 0) {
continue;
} else if (narrow_expolygons_index.size() == expolygons_size) {
// w11
surface_fills[i].params.pattern = ipConcentric;
} else {
params = surface_fills[i].params;
params.pattern = ipConcentric;
surface_fills.emplace_back(params);
surface_fills.back().region_id = surface_fills[i].region_id;
surface_fills.back().surface.surface_type = stInternalSolid;
surface_fills.back().surface.thickness = surface_fills[i].surface.thickness;
// surface_fills.back().region_id_group = surface_fills[i].region_id_group;
// surface_fills.back().no_overlap_expolygons = surface_fills[i].no_overlap_expolygons;
for (size_t j = 0; j < narrow_expolygons_index.size(); j++) {
surface_fills.back().expolygons.emplace_back(std::move(surface_fills[i].expolygons[narrow_expolygons_index[j]]));
}
for (int j = narrow_expolygons_index.size() - 1; j >= 0; j--) {
surface_fills[i].expolygons.erase(surface_fills[i].expolygons.begin() + narrow_expolygons_index[j]);
}
}
}
}
return surface_fills;
}

View File

@@ -488,6 +488,8 @@ static std::vector<std::string> s_Preset_print_options {
,"first_layer_travel_speed"
//B37
,"first_layer_infill_speed"
//w11
,"detect_narrow_internal_solid_infill"
};
static std::vector<std::string> s_Preset_filament_options {

View File

@@ -3519,6 +3519,16 @@ void PrintConfigDef::init_fff_params()
default: assert(false);
}
}
//w11
def = this->add("detect_narrow_internal_solid_infill", coBool);
def->label = L("Detect narrow internal solid infill");
def->category = L("Infill");
def->tooltip = L("This option will auto detect narrow internal solid infill area."
" If enabled, concentric pattern will be used for the area to speed printing up."
" Otherwise, rectilinear pattern is used defaultly.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true));
}
void PrintConfigDef::init_extruder_option_keys()

View File

@@ -571,6 +571,8 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, thick_bridges))
((ConfigOptionFloat, xy_size_compensation))
((ConfigOptionBool, wipe_into_objects))
//w11
((ConfigOptionBool, detect_narrow_internal_solid_infill))
)
PRINT_CONFIG_CLASS_DEFINE(

View File

@@ -1487,6 +1487,8 @@ void TabPrint::build()
optgroup->append_single_option_line("bridge_angle");
optgroup->append_single_option_line("only_retract_when_crossing_perimeters");
optgroup->append_single_option_line("infill_first");
//w11
optgroup->append_single_option_line("detect_narrow_internal_solid_infill");
page = add_options_page(L("Skirt and brim"), "skirt+brim");
category_path = "skirt-and-brim_133969#";
@@ -2283,12 +2285,6 @@ void TabFilament::toggle_options()
bool chamber_fan = printer_config->opt_bool("chamber_fan");
toggle_option("enable_volume_fan", chamber_fan);
int auxiliary_fan_speed = m_config->opt_int("enable_auxiliary_fan", 0);
if (auxiliary_fan_speed == 0)
toggle_option("disable_rapid_cooling_fan_first_layers", false);
else
toggle_option("disable_rapid_cooling_fan_first_layers", true);
}
}