From 4ef43af2dd5bc4d7c3a5651315f47daca55816c0 Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 15 Aug 2022 17:44:49 +0800 Subject: [PATCH] ENH: popup different warning message for unsupported sharp tails 1. unsupported sharp tails and large overhang have different messages 2. do not popup warning for total area (only warning for one single large overhang) Change-Id: I153e559915a92c6676468539cf619dafe915f997 (cherry picked from commit 67b593150f8de847d9b1999bf0d7a549eb1ef154) --- src/libslic3r/Print.hpp | 8 +++++++- src/libslic3r/PrintObject.cpp | 35 +++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index b07b6719e..3007eef29 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -49,6 +49,12 @@ struct groupedVolumeSlices ExPolygons slices; }; +enum SupportNecessaryType { + NoNeedSupp=0, + SharpTail, + LargeOverhang, +}; + namespace FillAdaptive { struct Octree; struct OctreeDeleter; @@ -457,7 +463,7 @@ private: std::pair prepare_adaptive_infill_data(); // BBS - bool is_support_necessary(); + SupportNecessaryType is_support_necessary(); // XYZ in scaled coordinates Vec3crd m_size; diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 511915736..d6d47f5c7 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -419,11 +419,17 @@ void PrintObject::generate_support_material() m_print->throw_if_canceled(); } else { // BBS: pop a warning if objects have significant amount of overhangs but support material is not enabled - if (this->is_support_necessary()) { + SupportNecessaryType sntype = this->is_support_necessary(); + if (sntype != NoNeedSupp) { m_print->set_status(50, L("Checking support necessity")); - - std::string warning_message = format(L("It seems object %s needs support to print. Please enable support generation."), this->model_object()->name); - this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning_message, PrintStateBase::SlicingNeedSupportOn); + if (sntype == SharpTail) { + std::string warning_message = format(L("It seems object %s has completely floating regions. Please re-orient the object or enable support generation."), + this->model_object()->name); + this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning_message, PrintStateBase::SlicingNeedSupportOn); + } else { + std::string warning_message = format(L("It seems object %s has large overhangs. Please enable support generation."), this->model_object()->name); + this->active_step_add_warning(PrintStateBase::WarningLevel::CRITICAL, warning_message, PrintStateBase::SlicingNeedSupportOn); + } } #if 0 @@ -2447,7 +2453,7 @@ template void PrintObject::remove_bridges_from_contacts( float max_bridge_length, bool break_bridge); -bool PrintObject::is_support_necessary() +SupportNecessaryType PrintObject::is_support_necessary() { static const double super_overhang_area_threshold = SQ(scale_(5.0)); @@ -2470,7 +2476,7 @@ bool PrintObject::is_support_necessary() for (const ExPolygon& expoly : layerm->raw_slices) { // detect sharp tail if (intersection_ex({ expoly }, lower_layer_offseted).empty()) - return true; + return SharpTail; } } @@ -2502,18 +2508,19 @@ bool PrintObject::is_support_necessary() double super_overhang_area = 0.0; for (Polygon& poly : super_overhang_polys) { bool is_ccw = poly.is_counter_clockwise(); + double area_ = poly.area(); if (is_ccw) { - if (super_overhang_area > super_overhang_area_threshold) - return true; - super_overhang_area = poly.area(); + if (area_ > super_overhang_area_threshold) + return LargeOverhang; + super_overhang_area += area_; } else { - super_overhang_area -= poly.area(); + super_overhang_area -= area_; } } - if (super_overhang_area > super_overhang_area_threshold) - return true; + //if (super_overhang_area > super_overhang_area_threshold) + // return LargeOverhang; // 3. check overhang distance const double distance_threshold_scaled = extrusion_width_scaled * 2; @@ -2528,10 +2535,10 @@ bool PrintObject::is_support_necessary() }), exceed_overhang.end()); if (!exceed_overhang.empty()) - return true; + return LargeOverhang; } - return false; + return NoNeedSupp; } static void project_triangles_to_slabs(ConstLayerPtrsAdaptor layers, const indexed_triangle_set &custom_facets, const Transform3f &tr, bool seam, std::vector &out)