From 1d4f41a2fd91823c03f724611066faf35d721cfb Mon Sep 17 00:00:00 2001 From: PavelMikus Date: Thu, 28 Jul 2022 14:46:16 +0200 Subject: [PATCH] improved option logic, custom setting for object soe that it uses the painted supports --- src/libslic3r/PrintObject.cpp | 33 +++++++++++--------- src/libslic3r/SupportSpotsGenerator.cpp | 2 +- src/libslic3r/SupportSpotsGenerator.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 18 ++++++++--- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index b085c7a07..2d473415c 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -398,6 +398,21 @@ void PrintObject::ironing() } } + +/* +std::vector problematic_layers = SupportSpotsGenerator::quick_search(this); + if (!problematic_layers.empty()) { + std::cout << "Object needs supports" << std::endl; + this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, + L("Supportable issues found. Consider enabling supports for this object")); + this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, + L("Supportable issues found. Consider enabling supports for this object")); + for (size_t index = 0; index < std::min(problematic_layers.size(), size_t(4)); ++index) { + this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, + format(L("Layer with issues: %1%"), problematic_layers[index] + 1)); + } + } + */ void PrintObject::generate_support_spots() { if (this->set_started(posSupportSpotsSearch)) { @@ -405,20 +420,10 @@ void PrintObject::generate_support_spots() << "Searching support spots - start"; m_print->set_status(75, L("Searching support spots")); - if (!this->m_config.support_material) { - std::vector problematic_layers = SupportSpotsGenerator::quick_search(this); - if (!problematic_layers.empty()) { - std::cout << "Object needs supports" << std::endl; - this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, - L("Supportable issues found. Consider enabling supports for this object")); - this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, - L("Supportable issues found. Consider enabling supports for this object")); - for (size_t index = 0; index < std::min(problematic_layers.size(), size_t(4)); ++index) { - this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, - format(L("Layer with issues: %1%"), problematic_layers[index] + 1)); - } - } - } else { + if (this->m_config.support_material && !this->m_config.support_material_auto && + std::all_of(this->model_object()->volumes.begin(), this->model_object()->volumes.end(), + [](const ModelVolume* mv){return mv->supported_facets.empty();}) + ) { SupportSpotsGenerator::Issues issues = SupportSpotsGenerator::full_search(this); auto obj_transform = this->trafo_centered(); for (ModelVolume *model_volume : this->model_object()->volumes) { diff --git a/src/libslic3r/SupportSpotsGenerator.cpp b/src/libslic3r/SupportSpotsGenerator.cpp index 59ed818b3..b75efd6ca 100644 --- a/src/libslic3r/SupportSpotsGenerator.cpp +++ b/src/libslic3r/SupportSpotsGenerator.cpp @@ -434,7 +434,7 @@ std::tuple reckon_islands( const std::vector &layer_lines, const Params ¶ms) { - //extract extrusions (connected paths from multiple lines) from the layer_lines. belonging to single polyline is determined by origin_entity ptr. + //extract extrusions (connected paths from multiple lines) from the layer_lines. Grouping by the same polyline is determined by common origin_entity ptr. // result is a vector of [start, end) index pairs into the layer_lines vector std::vector> extrusions; //start and end idx (one beyond last extrusion) [start,end) const ExtrusionEntity *current_ex = nullptr; diff --git a/src/libslic3r/SupportSpotsGenerator.hpp b/src/libslic3r/SupportSpotsGenerator.hpp index 705210561..6b94ceeaa 100644 --- a/src/libslic3r/SupportSpotsGenerator.hpp +++ b/src/libslic3r/SupportSpotsGenerator.hpp @@ -19,7 +19,7 @@ struct Params { const float max_acceleration = 9*1000.0f; // mm/s^2 ; max acceleration of object (bed) in XY (NOTE: The max hit is received by the object in the jerk phase, so the usual machine limits are too low) const float filament_density = 1.25e-3f ; // g/mm^3 ; Common filaments are very lightweight, so precise number is not that important const float bed_adhesion_yield_strength = 0.128f * 1e6f; //MPa * 1e^6 = (g*mm/s^2)/mm^2 = g/(mm*s^2); yield strength of the bed surface - const float material_yield_strength = 15.0f * 1e6f; // (g*mm/s^2)/mm^2; 33 MPa is yield strength of ABS, which has the lowest yield strength from common materials. + const float material_yield_strength = 33.0f * 1e6f; // (g*mm/s^2)/mm^2; 33 MPa is yield strength of ABS, which has the lowest yield strength from common materials. const float standard_extruder_conflict_force = 20.0f * gravity_constant; // force that can occasionally push the model due to various factors (filament leaks, small curling, ... ); const float malformations_additive_conflict_extruder_force = 150.0f * gravity_constant; // for areas with possible high layered curled filaments }; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index 7e8f0954e..494adb55a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -42,6 +42,7 @@ bool GLGizmoFdmSupports::on_init() m_shortcut_key = WXK_CONTROL_L; m_desc["auto_generate"] = _L("Auto-generate supports"); + m_desc["generating"] = _L("Generating supports..."); m_desc["clipping_of_view"] = _L("Clipping of view") + ": "; m_desc["reset_direction"] = _L("Reset direction"); m_desc["cursor_size"] = _L("Brush size") + ": "; @@ -156,10 +157,13 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l ImGui::Separator(); - bool generate = m_imgui->button(m_desc.at("auto_generate")); - if (generate) - auto_generate(); - + if (waiting_for_autogenerated_supports) { + m_imgui->text(m_desc.at("generating")); + } else { + bool generate = m_imgui->button(m_desc.at("auto_generate")); + if (generate) + auto_generate(); + } ImGui::Separator(); float position_before_text_y = ImGui::GetCursorPos().y; @@ -410,6 +414,7 @@ void GLGizmoFdmSupports::get_data_from_backend() if (mv->is_model_part()){ mesh_id++; mv->supported_facets.assign(mvs[mv->id().id]->supported_facets); + mv->supported_facets.touch(); m_triangle_selectors[mesh_id]->deserialize(mv->supported_facets.get_data(), true); m_triangle_selectors[mesh_id]->request_update_render_data(); } @@ -472,7 +477,7 @@ bool GLGizmoFdmSupports::has_backend_supports() const if (! mo) return false; - // find SlaPrintObject with this ID + // find PrintObject with this ID for (const PrintObject* po : m_parent.fff_print()->objects()) { if (po->model_object()->id() == mo->id()) return po->is_step_done(posSupportSpotsSearch); @@ -495,6 +500,9 @@ void GLGizmoFdmSupports::auto_generate() return vol->type() != ModelVolumeType::MODEL_PART || vol->supported_facets.empty(); }); + mo->config.set("support_material", true); + mo->config.set("support_material_auto", false); + MessageDialog dlg(GUI::wxGetApp().plater(), _L("Autogeneration will erase all currently painted areas.") + "\n\n" + _L("Are you sure you want to do it?") + "\n",