From 5e550709ffbd88e72554629e82ed754582b26368 Mon Sep 17 00:00:00 2001 From: Pavel Mikus Date: Mon, 20 Feb 2023 21:14:34 +0100 Subject: [PATCH 1/2] fix issue 9800 - Avoid Crossing Curled Overhangs Not Respecting Printer Bed Size Fix Avoid curled overhang functionality actually not working correctly, especially on multiple objects/instances --- src/libslic3r/GCode.cpp | 12 ++++++++++-- src/libslic3r/JumpPointSearch.cpp | 20 +++++++++++--------- src/libslic3r/JumpPointSearch.hpp | 14 ++++++++------ src/libslic3r/SupportSpotsGenerator.cpp | 2 ++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 16696e49a3..460ddc1114 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1032,6 +1032,10 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato m_pressure_equalizer = make_unique(print.config()); m_enable_extrusion_role_markers = (bool)m_pressure_equalizer; + if (print.config().avoid_crossing_curled_overhangs){ + this->m_avoid_crossing_curled_overhangs.init_bed_shape(get_bed_shape(print.config())); + } + // Write information on the generator. file.write_format("; %s\n\n", Slic3r::header_slic3r_generated().c_str()); @@ -2107,8 +2111,12 @@ LayerResult GCode::process_layer( if (this->config().avoid_crossing_curled_overhangs) { m_avoid_crossing_curled_overhangs.clear(); for (const ObjectLayerToPrint &layer_to_print : layers) { - m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.object_layer, Point(scaled(this->origin()))); - m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.support_layer, Point(scaled(this->origin()))); + if (layer_to_print.object() == nullptr) + continue; + for (const auto &instance : layer_to_print.object()->instances()) { + m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.object_layer, instance.shift); + m_avoid_crossing_curled_overhangs.add_obstacles(layer_to_print.support_layer, instance.shift); + } } } diff --git a/src/libslic3r/JumpPointSearch.cpp b/src/libslic3r/JumpPointSearch.cpp index 888db296b1..ef3dba45e7 100644 --- a/src/libslic3r/JumpPointSearch.cpp +++ b/src/libslic3r/JumpPointSearch.cpp @@ -1,5 +1,6 @@ #include "JumpPointSearch.hpp" #include "BoundingBox.hpp" +#include "ExPolygon.hpp" #include "Point.hpp" #include "libslic3r/AStar.hpp" #include "libslic3r/KDTreeIndirect.hpp" @@ -181,17 +182,18 @@ public: void JPSPathFinder::clear() { inpassable.clear(); - obstacle_max = Pixel(std::numeric_limits::min(), std::numeric_limits::min()); - obstacle_min = Pixel(std::numeric_limits::max(), std::numeric_limits::max()); + max_search_box.max = Pixel(std::numeric_limits::min(), std::numeric_limits::min()); + max_search_box.min = Pixel(std::numeric_limits::max(), std::numeric_limits::max()); + add_obstacles(bed_shape); } void JPSPathFinder::add_obstacles(const Lines &obstacles) { auto store_obstacle = [&](coord_t x, coord_t y) { - obstacle_max.x() = std::max(obstacle_max.x(), x); - obstacle_max.y() = std::max(obstacle_max.y(), y); - obstacle_min.x() = std::min(obstacle_min.x(), x); - obstacle_min.y() = std::min(obstacle_min.y(), y); + max_search_box.max.x() = std::max(max_search_box.max.x(), x); + max_search_box.max.y() = std::max(max_search_box.max.y(), y); + max_search_box.min.x() = std::min(max_search_box.min.x(), x); + max_search_box.min.y() = std::min(max_search_box.min.y(), y); inpassable.insert(Pixel{x, y}); return true; }; @@ -240,9 +242,9 @@ Polyline JPSPathFinder::find_path(const Point &p0, const Point &p1) }); } - BoundingBox search_box({start, end, obstacle_max, obstacle_min}); - search_box.max += Pixel(1, 1); - search_box.min -= Pixel(1, 1); + BoundingBox search_box = max_search_box; + search_box.max -= Pixel(1, 1); + search_box.min += Pixel(1, 1); BoundingBox bounding_square(Points{start, end}); bounding_square.max += Pixel(5, 5); diff --git a/src/libslic3r/JumpPointSearch.hpp b/src/libslic3r/JumpPointSearch.hpp index b09cc77477..5f3b5fee21 100644 --- a/src/libslic3r/JumpPointSearch.hpp +++ b/src/libslic3r/JumpPointSearch.hpp @@ -2,6 +2,7 @@ #define SRC_LIBSLIC3R_JUMPPOINTSEARCH_HPP_ #include "BoundingBox.hpp" +#include "Polygon.hpp" #include "libslic3r/Layer.hpp" #include "libslic3r/Point.hpp" #include "libslic3r/Polyline.hpp" @@ -16,18 +17,19 @@ class JPSPathFinder using Pixel = Point; std::unordered_set inpassable; coordf_t print_z; - Pixel obstacle_min; - Pixel obstacle_max; + BoundingBox max_search_box; + Lines bed_shape; const coord_t resolution = scaled(1.5); Pixel pixelize(const Point &p) { return p / resolution; } Point unpixelize(const Pixel &p) { return p * resolution; } public: - JPSPathFinder() { clear(); }; - void clear(); - void add_obstacles(const Lines &obstacles); - void add_obstacles(const Layer* layer, const Point& global_origin); + JPSPathFinder() = default; + void init_bed_shape(const Points &bed_shape) { this->bed_shape = (to_lines(Polygon{bed_shape})); }; + void clear(); + void add_obstacles(const Lines &obstacles); + void add_obstacles(const Layer *layer, const Point &global_origin); Polyline find_path(const Point &start, const Point &end); }; diff --git a/src/libslic3r/SupportSpotsGenerator.cpp b/src/libslic3r/SupportSpotsGenerator.cpp index e5f58f91e3..d45f82db87 100644 --- a/src/libslic3r/SupportSpotsGenerator.cpp +++ b/src/libslic3r/SupportSpotsGenerator.cpp @@ -1043,6 +1043,7 @@ void estimate_supports_malformations(SupportLayerPtrs &layers, float flow_width, AABBTreeLines::LinesDistancer prev_layer_lines{}; for (SupportLayer *l : layers) { + l->malformed_lines.clear(); std::vector current_layer_lines; for (const ExtrusionEntity *extrusion : l->support_fills.flatten().entities) { @@ -1114,6 +1115,7 @@ void estimate_malformations(LayerPtrs &layers, const Params ¶ms) LD prev_layer_lines{}; for (Layer *l : layers) { + l->malformed_lines.clear(); std::vector boundary_lines = l->lower_layer != nullptr ? to_unscaled_linesf(l->lower_layer->lslices) : std::vector(); AABBTreeLines::LinesDistancer prev_layer_boundary{std::move(boundary_lines)}; std::vector current_layer_lines; From 4e32b7ea5a54685d46c3afac0e0eb48f519b97eb Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 17 Feb 2023 15:05:32 +0100 Subject: [PATCH 2/2] Fix of Config wizard "no filaments selected for a printer" --- src/slic3r/GUI/ConfigWizard.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 35292d803b..b0e68dffff 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -2785,7 +2785,7 @@ bool ConfigWizard::priv::check_and_install_missing_materials(Technology technolo { // Walk over all installed Printer presets and verify whether there is a filament or SLA material profile installed at the same PresetBundle, // which is compatible with it. - const auto printer_models_missing_materials = [this, only_for_model_id](PrinterTechnology technology, const std::string §ion) + const auto printer_models_missing_materials = [this, only_for_model_id](PrinterTechnology technology, const std::string §ion, bool no_templates) { const std::map &appconfig_presets = appconfig_new.has_section(section) ? appconfig_new.get_section(section) : std::map(); std::set printer_models_without_material; @@ -2805,15 +2805,16 @@ bool ConfigWizard::priv::check_and_install_missing_materials(Technology technolo has_material = true; break; } - // find if preset.first is part of the templates profile (up is searching if preset.first is part of printer vendor preset) - for (const auto& bp : bundles) { - if (!bp.second.preset_bundle->vendors.empty() && bp.second.preset_bundle->vendors.begin()->second.templates_profile) { - const PresetCollection& template_materials = bp.second.preset_bundle->materials(technology); - const Preset* template_material = template_materials.find_preset(preset.first, false); - if (template_material && is_compatible_with_printer(PresetWithVendorProfile(*template_material, &bp.second.preset_bundle->vendors.begin()->second), PresetWithVendorProfile(printer, nullptr))) { - has_material = true; - break; + if (!no_templates) { + for (const auto& bp : bundles) { + if (!bp.second.preset_bundle->vendors.empty() && bp.second.preset_bundle->vendors.begin()->second.templates_profile) { + const PresetCollection& template_materials = bp.second.preset_bundle->materials(technology); + const Preset* template_material = template_materials.find_preset(preset.first, false); + if (template_material && is_compatible_with_printer(PresetWithVendorProfile(*template_material, &bp.second.preset_bundle->vendors.begin()->second), PresetWithVendorProfile(printer, nullptr))) { + has_material = true; + break; + } } } } @@ -2872,8 +2873,10 @@ bool ConfigWizard::priv::check_and_install_missing_materials(Technology technolo return out; }; + bool no_templates = wxGetApp().app_config->get("no_templates") == "1"; + if (any_fff_selected && (technology & T_FFF)) { - std::set printer_models_without_material = printer_models_missing_materials(ptFFF, AppConfig::SECTION_FILAMENTS); + std::set printer_models_without_material = printer_models_missing_materials(ptFFF, AppConfig::SECTION_FILAMENTS, no_templates); if (! printer_models_without_material.empty()) { if (only_for_model_id.empty()) ask_and_select_default_materials( @@ -2891,7 +2894,7 @@ bool ConfigWizard::priv::check_and_install_missing_materials(Technology technolo } if (any_sla_selected && (technology & T_SLA)) { - std::set printer_models_without_material = printer_models_missing_materials(ptSLA, AppConfig::SECTION_MATERIALS); + std::set printer_models_without_material = printer_models_missing_materials(ptSLA, AppConfig::SECTION_MATERIALS, no_templates); if (! printer_models_without_material.empty()) { if (only_for_model_id.empty()) ask_and_select_default_materials(