From f9825bb6f438aefcc81d5f0179d16915b2ccaedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 4 Jan 2024 14:42:51 +0100 Subject: [PATCH 1/7] Silence warnings in ExtrusionSimulator about unused variables that were there just for debugging purposes. --- src/libslic3r/ExtrusionSimulator.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/ExtrusionSimulator.cpp b/src/libslic3r/ExtrusionSimulator.cpp index 6408c4b144..fcd89b1f2d 100644 --- a/src/libslic3r/ExtrusionSimulator.cpp +++ b/src/libslic3r/ExtrusionSimulator.cpp @@ -699,13 +699,16 @@ void gcode_spread_points( } } */ - float area_total = 0; - float volume_total = 0; - float volume_excess = 0; - float volume_deficit = 0; - size_t n_cells = 0; - float area_circle_total = 0; + + float area_total = 0; + float volume_total = 0; + size_t n_cells = 0; + #if 0 + float volume_excess = 0; + float volume_deficit = 0; + float area_circle_total = 0; + // The intermediate lines. for (int j = row_first; j < row_last; ++ j) { const std::pair &span1 = spans[j]; @@ -759,7 +762,11 @@ void gcode_spread_points( cell.volume = acc[j][i]; cell.area = mask[j][i]; assert(cell.area >= 0.f && cell.area <= 1.000001f); - area_circle_total += area; + +#if 0 + area_circle_total += area; +#endif + if (cell.area < area) cell.area = area; cell.fraction_covered = std::clamp((cell.area > 0) ? (area / cell.area) : 0, 0.f, 1.f); @@ -769,10 +776,15 @@ void gcode_spread_points( } float cell_height = cell.volume / cell.area; cell.excess_height = cell_height - height_target; + +#if 0 + area_circle_total += area; if (cell.excess_height > 0.f) volume_excess += cell.excess_height * cell.area * cell.fraction_covered; else volume_deficit -= cell.excess_height * cell.area * cell.fraction_covered; +#endif + volume_total += cell.volume * cell.fraction_covered; area_total += cell.area * cell.fraction_covered; } From 413241fcbc936a1e6c565c1d58fb8943c595c65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 4 Jan 2024 14:44:30 +0100 Subject: [PATCH 2/7] Remove unused variable path_length from GCodeGenerator::_extrude(). This variable hasn't been used since the beginning. --- src/libslic3r/GCode.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 8853ad9ce6..30df60c786 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -3142,7 +3142,7 @@ std::string GCodeGenerator::_extrude( gcode += m_writer.set_speed(F, "", cooling_marker_setspeed_comments); if (dynamic_speed_and_fan_speed.second >= 0) gcode += ";_SET_FAN_SPEED" + std::to_string(int(dynamic_speed_and_fan_speed.second)) + "\n"; - double path_length = 0.; + std::string comment; if (m_config.gcode_comments) { comment = description; @@ -3176,16 +3176,13 @@ std::string GCodeGenerator::_extrude( } if (radius == 0) { // Extrude line segment. - if (const double line_length = (p - prev).norm(); line_length > 0) { - path_length += line_length; + if (const double line_length = (p - prev).norm(); line_length > 0) gcode += m_writer.extrude_to_xy(p, e_per_mm * line_length, comment); - } } else { double angle = Geometry::ArcWelder::arc_angle(prev.cast(), p.cast(), double(radius)); assert(angle > 0); const double line_length = angle * std::abs(radius); - path_length += line_length; - const double dE = e_per_mm * line_length; + const double dE = e_per_mm * line_length; assert(dE > 0); gcode += m_writer.extrude_to_xy_G2G3IJ(p, ij, it->ccw(), dE, comment); } From 41aff15c515db78c8fae1970a68123ead7341459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 4 Jan 2024 14:50:49 +0100 Subject: [PATCH 3/7] Remove unused lambda capture plater in lambda function fix_and_update_progress() inside check_objects_after_cut(). --- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 48d119e7dc..9873d2f6d0 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -3310,7 +3310,7 @@ static void check_objects_after_cut(const ModelObjectPtrs& objects) for (int obj_idx : err_objects_idxs) model_names.push_back(objects[obj_idx]->name); - auto fix_and_update_progress = [plater, model_names, &objects](const int obj_idx, int model_idx, + auto fix_and_update_progress = [model_names, &objects](const int obj_idx, int model_idx, wxProgressDialog& progress_dlg, std::vector& succes_models, std::vector>& failed_models) -> bool From 69b29a202fd8a4a768e7fd61f114b4b92ce07f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 4 Jan 2024 14:53:39 +0100 Subject: [PATCH 4/7] Remove forgotten variable m_wifi_config_dialog_was_declined from Slic3r::GUI::GUI_App class. --- src/slic3r/GUI/GUI_App.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 4e2854d3aa..b1dc3cb99b 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -404,7 +404,6 @@ private: bool m_datadir_redefined { false }; bool m_wifi_config_dialog_shown { false }; - bool m_wifi_config_dialog_was_declined { false }; }; DECLARE_APP(GUI_App) From a98b97643e89004e5bed2ce1d9f4132955bc35f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 4 Jan 2024 15:00:47 +0100 Subject: [PATCH 5/7] Avoid unnecessary copy of the variable 'pair' in WifiConfigDialog::rescan_networks(). --- src/slic3r/GUI/WifiConfigDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/WifiConfigDialog.cpp b/src/slic3r/GUI/WifiConfigDialog.cpp index 6b088d8ad5..e5be758be5 100644 --- a/src/slic3r/GUI/WifiConfigDialog.cpp +++ b/src/slic3r/GUI/WifiConfigDialog.cpp @@ -192,7 +192,7 @@ void WifiConfigDialog::rescan_networks(bool select) std::string current = m_wifi_scanner->get_current_ssid(); const auto& map = m_wifi_scanner->get_map(); m_ssid_combo->Clear(); - for (const auto pair : map) { + for (const auto &pair : map) { m_ssid_combo->Append(pair.first); // select ssid of current network (if connected) if (current == pair.first) From 7e8f45a302a501cf60cf67b0eefbded2f6b03c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 4 Jan 2024 15:06:23 +0100 Subject: [PATCH 6/7] Remove unused variable 'some_compatible' from ExtruderFilaments::update_compatible_internal(). This variable hasn't been used since the beginning. --- src/libslic3r/Preset.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 44c29c32c2..75dda312ef 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -2253,7 +2253,6 @@ size_t ExtruderFilaments::update_compatible_internal(const PresetWithVendorProfi const ConfigOption* opt = active_printer.preset.config.option("nozzle_diameter"); if (opt) config.set_key_value("num_extruders", new ConfigOptionInt((int)static_cast(opt)->values.size())); - bool some_compatible = false; // Adjust printer preset config to the first extruder from m_extruder_id Preset printer_preset_adjusted = active_printer.preset; @@ -2281,7 +2280,6 @@ size_t ExtruderFilaments::update_compatible_internal(const PresetWithVendorProfi const PresetWithVendorProfile this_preset_with_vendor_profile = m_filaments->get_preset_with_vendor_profile(*preset); bool was_compatible = extr_filament.is_compatible; extr_filament.is_compatible = is_compatible_with_printer(this_preset_with_vendor_profile, active_printer_adjusted, &config); - some_compatible |= extr_filament.is_compatible; if (active_print != nullptr) extr_filament.is_compatible &= is_compatible_with_print(this_preset_with_vendor_profile, *active_print, active_printer_adjusted); if (!extr_filament.is_compatible && is_selected && From 229946a25c7da5b1810faf280c10a842eb1aa596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Fri, 5 Jan 2024 16:28:04 +0100 Subject: [PATCH 7/7] Reorganize getArea() in TreeModelVolumes to silence the warning ( may be used uninitialized in this function). This warning was shown because the previous code was triggering a bug in GCC. More about the bug can be found here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465. --- src/libslic3r/Support/TreeModelVolumes.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Support/TreeModelVolumes.hpp b/src/libslic3r/Support/TreeModelVolumes.hpp index 57ca9fae7a..eeabccd55e 100644 --- a/src/libslic3r/Support/TreeModelVolumes.hpp +++ b/src/libslic3r/Support/TreeModelVolumes.hpp @@ -244,12 +244,16 @@ private: */ std::optional> getArea(const TreeModelVolumes::RadiusLayerPair &key) const { std::lock_guard guard(m_mutex); + if (key.second >= LayerIndex(m_data.size())) - return std::optional>{}; - const auto &layer = m_data[key.second]; + return std::nullopt; + + const LayerData &layer = m_data[key.second]; auto it = layer.find(key.first); - return it == layer.end() ? - std::optional>{} : std::optional>{ it->second }; + if (it == layer.end()) + return std::nullopt; + + return std::optional>{it->second}; } // Get a collision area at a given layer for a radius that is a lower or equial to the key radius. std::optional>> get_lower_bound_area(const TreeModelVolumes::RadiusLayerPair &key) const {