From f6c663cc703515c7d852ba8a893ee8ea681975fb Mon Sep 17 00:00:00 2001 From: remi durand Date: Wed, 2 Jun 2021 21:15:02 +0200 Subject: [PATCH] allow >1mm width extrusions in gcode viewer supermerill/SuperSlicer#840 there is now a width limit at 10*height if guessed width-height gcode --- src/libslic3r/GCode/GCodeProcessor.cpp | 30 +++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 5ef3b661e..fdc1ea236 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1903,21 +1903,27 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) #if ENABLE_TOOLPATHS_WIDTH_HEIGHT_FROM_GCODE if (m_forced_width > 0.0f) m_width = m_forced_width; - else if (m_extrusion_role == erExternalPerimeter) + else { + if (m_extrusion_role == erExternalPerimeter) #else - if (m_extrusion_role == erExternalPerimeter) + { + if (m_extrusion_role == erExternalPerimeter) #endif // ENABLE_TOOLPATHS_WIDTH_HEIGHT_FROM_GCODE - // cross section: rectangle - m_width = delta_pos[E] * static_cast(M_PI * sqr(1.05f * filament_radius)) / (delta_xyz * m_height); - else if (is_bridge(m_extrusion_role) || m_extrusion_role == erNone) - // cross section: circle - m_width = static_cast(m_filament_diameters[m_extruder_id]) * std::sqrt(delta_pos[E] / delta_xyz); - else - // cross section: rectangle + 2 semicircles - m_width = delta_pos[E] * static_cast(M_PI * sqr(filament_radius)) / (delta_xyz * m_height) + static_cast(1.0 - 0.25 * M_PI) * m_height; + // cross section: rectangle + m_width = delta_pos[E] * static_cast(M_PI * sqr(1.05f * filament_radius)) / (delta_xyz * m_height); + else if (is_bridge(m_extrusion_role) || m_extrusion_role == erNone) + // cross section: circle + m_width = static_cast(m_filament_diameters[m_extruder_id]) * std::sqrt(delta_pos[E] / delta_xyz); + else + // cross section: rectangle + 2 semicircles + m_width = delta_pos[E] * static_cast(M_PI * sqr(filament_radius)) / (delta_xyz * m_height) + static_cast(1.0 - 0.25 * M_PI) * m_height; - // clamp width to avoid artifacts which may arise from wrong values of m_height - m_width = std::min(m_width, std::max(1.0f, 4.0f * m_height)); + // if teh value seems wrong, fall back to circular extrusion from flow + if (m_width > m_height * 10 || m_width < m_height) { + m_width = 2 * std::sqrt(m_mm3_per_mm / float(PI)); + m_height = m_width; + } + } #if ENABLE_GCODE_VIEWER_DATA_CHECKING m_width_compare.update(m_width, m_extrusion_role);