Fix usage of most of the multi-variant parameters

This commit is contained in:
Noisyfox
2026-05-20 23:30:43 +08:00
parent 353e9519f0
commit 8a6573db19
11 changed files with 122 additions and 115 deletions

View File

@@ -4573,12 +4573,12 @@ LayerResult GCode::process_layer(
}
case CalibMode::Calib_VFA_Tower: {
auto _speed = print.calib_params().start + std::floor(print_z / 5.0) * print.calib_params().step;
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloat(std::round(_speed)));
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloatsNullable({std::round(_speed)}));
break;
}
case CalibMode::Calib_Vol_speed_Tower: {
auto _speed = print.calib_params().start + print_z * print.calib_params().step;
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloat(std::round(_speed)));
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloatsNullable({std::round(_speed)}));
break;
}
case CalibMode::Calib_Retraction_tower: {

View File

@@ -2971,26 +2971,26 @@ void Model::setPrintSpeedTable(const DynamicPrintConfig& config, const PrintConf
printSpeedMap.maxSpeed = printSpeedMap.perimeterSpeed;
}
if (config.has("outer_wall_speed")) {
printSpeedMap.externalPerimeterSpeed = config.opt_float("outer_wall_speed");
printSpeedMap.externalPerimeterSpeed = config.opt_float_nullable("outer_wall_speed", 0);
printSpeedMap.maxSpeed = std::max(printSpeedMap.maxSpeed, printSpeedMap.externalPerimeterSpeed);
}
if (config.has("sparse_infill_speed")) {
printSpeedMap.infillSpeed = config.opt_float("sparse_infill_speed");
printSpeedMap.infillSpeed = config.opt_float_nullable("sparse_infill_speed", 0);
if (printSpeedMap.infillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.infillSpeed;
}
if (config.has("internal_solid_infill_speed")) {
printSpeedMap.solidInfillSpeed = config.opt_float("internal_solid_infill_speed");
printSpeedMap.solidInfillSpeed = config.opt_float_nullable("internal_solid_infill_speed", 0);
if (printSpeedMap.solidInfillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.solidInfillSpeed;
}
if (config.has("top_surface_speed")) {
printSpeedMap.topSolidInfillSpeed = config.opt_float("top_surface_speed");
printSpeedMap.topSolidInfillSpeed = config.opt_float_nullable("top_surface_speed", 0);
if (printSpeedMap.topSolidInfillSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.topSolidInfillSpeed;
}
if (config.has("support_speed")) {
printSpeedMap.supportSpeed = config.opt_float("support_speed");
printSpeedMap.supportSpeed = config.opt_float_nullable("support_speed", 0);
if (printSpeedMap.supportSpeed > printSpeedMap.maxSpeed)
printSpeedMap.maxSpeed = printSpeedMap.supportSpeed;
@@ -3226,17 +3226,17 @@ double Model::findMaxSpeed(const ModelObject* object) {
externalPerimeterSpeedObj = Model::printSpeedMap.externalPerimeterSpeed / Model::printSpeedMap.perimeterSpeed * perimeterSpeedObj;
}
if (objectKey == "sparse_infill_speed")
infillSpeedObj = object->config.opt_float(objectKey);
infillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
if (objectKey == "internal_solid_infill_speed")
solidInfillSpeedObj = object->config.opt_float(objectKey);
solidInfillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
if (objectKey == "top_surface_speed")
topSolidInfillSpeedObj = object->config.opt_float(objectKey);
topSolidInfillSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
if (objectKey == "support_speed")
supportSpeedObj = object->config.opt_float(objectKey);
supportSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
if (objectKey == "outer_wall_speed")
externalPerimeterSpeedObj = object->config.opt_float(objectKey);
externalPerimeterSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
if (objectKey == "small_perimeter_speed")
smallPerimeterSpeedObj = object->config.opt_float(objectKey);
smallPerimeterSpeedObj = object->config.get().opt_float_nullable(objectKey, 0);
}
objMaxSpeed = std::max(perimeterSpeedObj, std::max(externalPerimeterSpeedObj, std::max(infillSpeedObj, std::max(solidInfillSpeedObj, std::max(topSolidInfillSpeedObj, std::max(supportSpeedObj, std::max(smallPerimeterSpeedObj, objMaxSpeed)))))));
if (objMaxSpeed <= 0) objMaxSpeed = 250.;

View File

@@ -868,13 +868,15 @@ void PrintObject::generate_support_material()
void PrintObject::estimate_curled_extrusions()
{
if (this->set_started(posEstimateCurledExtrusions)) {
if ( std::any_of(this->print()->m_print_regions.begin(), this->print()->m_print_regions.end(),
[](const PrintRegion *region) { return region->config().enable_overhang_speed.getBool(); })) {
if ( std::any_of(this->print()->m_print_regions.begin(), this->print()->m_print_regions.end(), [](const PrintRegion* region) {
const auto& cfg = region->config().enable_overhang_speed.values;
return std::any_of(cfg.begin(), cfg.end(), [](const unsigned char v) { return (bool) v; });
})) {
// Estimate curling of support material and add it to the malformaition lines of each layer
float support_flow_width = support_material_flow(this, this->config().layer_height).width();
SupportSpotsGenerator::Params params{this->print()->m_config.filament_type.values,
float(this->print()->default_object_config().inner_wall_acceleration.getFloat()),
/*float(this->print()->default_object_config().inner_wall_acceleration.getFloat()),*/
this->config().raft_layers.getInt(), this->config().brim_type.value,
float(this->config().brim_width.getFloat())};
SupportSpotsGenerator::estimate_malformations(this->layers(), params);
@@ -1121,11 +1123,11 @@ bool PrintObject::invalidate_state_by_config_options(
// todo multi_extruders: Parameter migration between single and double extruder printers
auto is_gap_fill_changed_state_due_to_speed = [&opt_key, &old_config, &new_config]() -> bool {
if (opt_key == "gap_infill_speed") {
const auto *old_gap_fill_speed = old_config.option<ConfigOptionFloat>(opt_key);
const auto *new_gap_fill_speed = new_config.option<ConfigOptionFloat>(opt_key);
const auto *old_gap_fill_speed = old_config.option<ConfigOptionFloatsNullable>(opt_key);
const auto *new_gap_fill_speed = new_config.option<ConfigOptionFloatsNullable>(opt_key);
assert(old_gap_fill_speed && new_gap_fill_speed);
return (old_gap_fill_speed->value > 0.f && new_gap_fill_speed->value == 0.f) ||
(old_gap_fill_speed->value == 0.f && new_gap_fill_speed->value > 0.f);
return (old_gap_fill_speed->values.size() != new_gap_fill_speed->values.size())
|| (old_gap_fill_speed->values != new_gap_fill_speed->values);
}
return false;
};

View File

@@ -18,8 +18,8 @@ namespace SupportSpotsGenerator {
struct Params
{
Params(
const std::vector<std::string> &filament_types, float max_acceleration, int raft_layers_count, BrimType brim_type, float brim_width)
: max_acceleration(max_acceleration), raft_layers_count(raft_layers_count), brim_type(brim_type), brim_width(brim_width)
const std::vector<std::string> &filament_types/*, float max_acceleration*/, int raft_layers_count, BrimType brim_type, float brim_width)
: /*max_acceleration(max_acceleration), */raft_layers_count(raft_layers_count), brim_type(brim_type), brim_width(brim_width)
{
if (filament_types.size() > 1) {
BOOST_LOG_TRIVIAL(warning)
@@ -36,8 +36,8 @@ struct Params
// the algorithm should use the following units for all computations: distance [mm], mass [g], time [s], force [g*mm/s^2]
const float bridge_distance = 16.0f; // mm
const float max_acceleration; // mm/s^2 ; max acceleration of object in XY -- should be applicable only to printers with bed slinger,
// however we do not have such info yet. The force is usually small anyway, so not such a big deal to include it everytime
// const float max_acceleration; // mm/s^2 ; max acceleration of object in XY -- should be applicable only to printers with bed slinger,
// // however we do not have such info yet. The force is usually small anyway, so not such a big deal to include it everytime
const int raft_layers_count;
std::string filament_type;

View File

@@ -16,7 +16,7 @@ float CalibPressureAdvance::find_optimal_PA_speed(const DynamicPrintConfig &conf
const float nozzle_diameter = config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(extruder_id);
if (line_width <= 0.) line_width = Flow::auto_extrusion_width(frPerimeter, nozzle_diameter);
Flow pattern_line = Flow(line_width, layer_height, nozzle_diameter);
auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option<ConfigOptionFloat>("outer_wall_speed")->value),
auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option<ConfigOptionFloatsNullable>("outer_wall_speed")->get_at(extruder_id)),
filament_max_volumetric_speed / pattern_line.mm3_per_mm());
return std::floor(pa_speed);

View File

@@ -280,7 +280,7 @@ private:
struct SuggestedConfigCalibPAPattern
{
const std::vector<std::pair<std::string, double>> float_pairs{{"initial_layer_speed", 30}};
const std::vector<std::pair<std::string, std::vector<double>>> floats_pairs{{"initial_layer_speed", {30}}};
const std::vector<std::pair<std::string, double>> nozzle_ratio_pairs{{"line_width", 112.5}, {"initial_layer_line_width", 140}};
@@ -312,13 +312,13 @@ public:
protected:
// todo multi_extruders:
double speed_first_layer() const { return m_config.option<ConfigOptionFloat>("initial_layer_speed")->value; };
double speed_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_speed")->value; };
double accel_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_acceleration")->value; }
double speed_first_layer() const { return m_config.get_abs_value_at("initial_layer_speed", m_params.extruder_id); };
double speed_perimeter() const { return m_config.get_abs_value_at("outer_wall_speed", m_params.extruder_id); };
double accel_perimeter() const { return m_config.get_abs_value_at("outer_wall_acceleration", m_params.extruder_id); }
double line_width_first_layer() const
{
// TODO: FIXME: find out current filament/extruder?
const double nozzle_diameter = m_config.opt_float("nozzle_diameter", 0);
const double nozzle_diameter = m_config.opt_float("nozzle_diameter", m_params.extruder_id);
return m_config.get_abs_value("initial_layer_line_width", nozzle_diameter);
};
double line_width() const;