From 5807135a1fec3030e54987b404ad9449c753dc87 Mon Sep 17 00:00:00 2001 From: SoftFever <103989404+SoftFever@users.noreply.github.com> Date: Sat, 12 Aug 2023 15:38:22 +0800 Subject: [PATCH] Fixed an issue that internal_bridge_speed is applied to external bridge infills A new extrusion role - erInternalBridgeInfill is introduced. SuperSlicer's implementation is referenced. Signed-off-by: SoftFever <103989404+SoftFever@users.noreply.github.com> --- src/libslic3r/ExtrusionEntity.cpp | 3 +++ src/libslic3r/ExtrusionEntity.hpp | 4 ++++ src/libslic3r/Fill/Fill.cpp | 19 +++++++++++++------ src/libslic3r/GCode.cpp | 5 +++-- src/libslic3r/GCode/GCodeProcessor.cpp | 14 ++++++++++++-- src/libslic3r/SupportMaterial.cpp | 3 ++- src/libslic3r/Surface.hpp | 1 + src/slic3r/GUI/GCodeViewer.cpp | 3 ++- 8 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/ExtrusionEntity.cpp b/src/libslic3r/ExtrusionEntity.cpp index e9c20ee7e..e4b49c9a8 100644 --- a/src/libslic3r/ExtrusionEntity.cpp +++ b/src/libslic3r/ExtrusionEntity.cpp @@ -354,6 +354,7 @@ std::string ExtrusionEntity::role_to_string(ExtrusionRole role) case erBottomSurface : return L("Bottom surface"); case erIroning : return L("Ironing"); case erBridgeInfill : return L("Bridge"); + case erInternalBridgeInfill : return L("Internal Bridge"); case erGapFill : return L("Gap infill"); case erSkirt : return ("Skirt"); case erBrim : return ("Brim"); @@ -388,6 +389,8 @@ ExtrusionRole ExtrusionEntity::string_to_role(const std::string_view role) return erIroning; else if (role == L("Bridge")) return erBridgeInfill; + else if (role == L("Internal Bridge")) + return erInternalBridgeInfill; else if (role == L("Gap infill")) return erGapFill; else if (role == ("Skirt")) diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index 7d6d5fbc2..159c08e7e 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -28,6 +28,7 @@ enum ExtrusionRole : uint8_t { erBottomSurface, erIroning, erBridgeInfill, + erInternalBridgeInfill, erGapFill, erSkirt, erBrim, @@ -69,6 +70,7 @@ inline bool is_external_perimeter(ExtrusionRole role) inline bool is_infill(ExtrusionRole role) { return role == erBridgeInfill + || role == erInternalBridgeInfill || role == erInternalInfill || role == erSolidInfill || role == erTopSolidInfill @@ -84,6 +86,7 @@ inline bool is_top_surface(ExtrusionRole role) inline bool is_solid_infill(ExtrusionRole role) { return role == erBridgeInfill + || role == erInternalBridgeInfill || role == erSolidInfill || role == erTopSolidInfill || role == erBottomSurface @@ -92,6 +95,7 @@ inline bool is_solid_infill(ExtrusionRole role) inline bool is_bridge(ExtrusionRole role) { return role == erBridgeInfill + || role == erInternalBridgeInfill || role == erOverhangPerimeter; } diff --git a/src/libslic3r/Fill/Fill.cpp b/src/libslic3r/Fill/Fill.cpp index 952352bb0..af738c6be 100644 --- a/src/libslic3r/Fill/Fill.cpp +++ b/src/libslic3r/Fill/Fill.cpp @@ -174,12 +174,19 @@ std::vector group_fills(const Layer &layer) } else if (params.density <= 0) continue; - params.extrusion_role = - is_bridge ? - erBridgeInfill : - (surface.is_solid() ? - (surface.is_top() ? erTopSolidInfill : (surface.is_bottom()? erBottomSurface : erSolidInfill)) : - erInternalInfill); + params.extrusion_role = erInternalInfill; + if (is_bridge) { + if(surface.is_internal_bridge()) + params.extrusion_role = erInternalBridgeInfill; + else + params.extrusion_role = erBridgeInfill; + } else if (surface.is_solid()) { + if (surface.is_top()) { + params.extrusion_role = erTopSolidInfill; + } else { + params.extrusion_role = erSolidInfill; + } + } params.bridge_angle = float(surface.bridge_angle); params.angle = float(Geometry::deg2rad(region_config.infill_direction.value)); diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 203f6a91e..b604c1cc1 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1,3 +1,4 @@ +#include "PrintConfig.hpp" #include "libslic3r.h" #include "I18N.hpp" #include "GCode.hpp" @@ -4045,9 +4046,9 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, speed = new_speed == 0.0 ? speed : new_speed; } } - else if(path.role() == erBridgeInfill) { + else if(path.role() == erInternalBridgeInfill) { speed = m_config.get_abs_value("internal_bridge_speed"); - } else if (path.role() == erOverhangPerimeter || path.role() == erSupportTransition) { + } else if (path.role() == erOverhangPerimeter || path.role() == erSupportTransition || path.role() == erBridgeInfill) { speed = m_config.get_abs_value("bridge_speed"); } else if (path.role() == erInternalInfill) { speed = m_config.get_abs_value("sparse_infill_speed"); diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 09c6cdf60..b6643443d 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1,3 +1,4 @@ +#include "ExtrusionEntity.hpp" #include "libslic3r/libslic3r.h" #include "libslic3r/Utils.hpp" #include "libslic3r/Print.hpp" @@ -2369,6 +2370,13 @@ bool GCodeProcessor::process_simplify3d_tags(const std::string_view comment) return true; } + // ; internal bridge + pos = cmt.find(" internal bridge"); + if (pos == 0) { + set_extrusion_role(erInternalBridgeInfill); + return true; + } + // ; support pos = cmt.find(" support"); if (pos == 0) { @@ -2520,6 +2528,8 @@ bool GCodeProcessor::process_ideamaker_tags(const std::string_view comment) set_extrusion_role(erInternalInfill); else if (type == "BRIDGE") set_extrusion_role(erBridgeInfill); + else if (type == "INTERNAL BRIDGE") + set_extrusion_role(erInternalBridgeInfill); else if (type == "SUPPORT") set_extrusion_role(erSupportMaterial); else { @@ -2792,7 +2802,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) else if (m_extrusion_role == erExternalPerimeter) // cross section: rectangle m_width = delta_pos[E] * static_cast(M_PI * sqr(1.05f * filament_radius)) / (delta_xyz * m_height); - else if (m_extrusion_role == erBridgeInfill || m_extrusion_role == erNone) + else if (m_extrusion_role == erBridgeInfill || m_extrusion_role == erInternalBridgeInfill || m_extrusion_role == erNone) // cross section: circle m_width = static_cast(m_result.filament_diameters[m_extruder_id]) * std::sqrt(delta_pos[E] / delta_xyz); else @@ -3249,7 +3259,7 @@ void GCodeProcessor::process_G2_G3(const GCodeReader::GCodeLine& line) else if (m_extrusion_role == erExternalPerimeter) //BBS: cross section: rectangle m_width = delta_pos[E] * static_cast(M_PI * sqr(1.05f * filament_radius)) / (delta_xyz * m_height); - else if (m_extrusion_role == erBridgeInfill || m_extrusion_role == erNone) + else if (m_extrusion_role == erBridgeInfill || m_extrusion_role == erInternalBridgeInfill || m_extrusion_role == erNone) //BBS: cross section: circle m_width = static_cast(m_result.filament_diameters[m_extruder_id]) * std::sqrt(delta_pos[E] / delta_xyz); else diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index f5b2004fb..af531ea73 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -1,4 +1,5 @@ #include "ClipperUtils.hpp" +#include "ExtrusionEntity.hpp" #include "ExtrusionEntityCollection.hpp" #include "Layer.hpp" #include "Print.hpp" @@ -1325,7 +1326,7 @@ namespace SupportMaterialInternal { for (const ExtrusionEntity *ee2 : static_cast(ee)->entities) { assert(! ee2->is_collection()); assert(! ee2->is_loop()); - if (ee2->role() == erBridgeInfill) + if (ee2->role() == erBridgeInfill || ee2->role() == erInternalBridgeInfill) return true; } } diff --git a/src/libslic3r/Surface.hpp b/src/libslic3r/Surface.hpp index 84bbbfb35..42bf67e6d 100644 --- a/src/libslic3r/Surface.hpp +++ b/src/libslic3r/Surface.hpp @@ -104,6 +104,7 @@ public: bool is_top() const { return this->surface_type == stTop; } bool is_bottom() const { return this->surface_type == stBottom || this->surface_type == stBottomBridge; } bool is_bridge() const { return this->surface_type == stBottomBridge || this->surface_type == stInternalBridge; } + bool is_internal_bridge() const { return this->surface_type == stInternalBridge; } bool is_external() const { return this->is_top() || this->is_bottom(); } bool is_internal() const { return ! this->is_external(); } bool is_solid() const { return this->is_external() || this->surface_type == stInternalSolid || this->surface_type == stInternalBridge; } diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 7c2d91f99..6adb122d9 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -733,7 +733,8 @@ const std::vector GCodeViewer::Extrusion_Role_Colors {{ { 0.94f, 0.25f, 0.25f, 1.0f }, // erTopSolidInfill { 0.40f, 0.36f, 0.78f, 1.0f }, // erBottomSurface { 1.00f, 0.55f, 0.41f, 1.0f }, // erIroning - { 0.30f, 0.50f, 0.73f, 1.0f }, // erBridgeInfill + { 0.30f, 0.40f, 0.63f, 1.0f }, // erBridgeInfill + { 0.30f, 0.50f, 0.73f, 1.0f }, // erInternalBridgeInfill { 1.00f, 1.00f, 1.00f, 1.0f }, // erGapFill { 0.00f, 0.53f, 0.43f, 1.0f }, // erSkirt { 0.00f, 0.23f, 0.43f, 1.0f }, // erBrim