From e731bfffa8b4fdea960e5f3d08bae2a4e1155ed9 Mon Sep 17 00:00:00 2001 From: Ian Bassi Date: Tue, 23 Dec 2025 09:47:22 -0300 Subject: [PATCH] Enforce strictly increasing flow compensation factors Added a check to ensure that flow compensation factors in SmallAreaInfillFlowCompensator strictly increase with extrusion length, throwing an exception if this condition is not met. This improves input validation and prevents invalid compensation models. --- src/libslic3r/GCode/SmallAreaInfillFlowCompensator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/GCode/SmallAreaInfillFlowCompensator.cpp b/src/libslic3r/GCode/SmallAreaInfillFlowCompensator.cpp index 4a5e3606bb..e4e9694775 100644 --- a/src/libslic3r/GCode/SmallAreaInfillFlowCompensator.cpp +++ b/src/libslic3r/GCode/SmallAreaInfillFlowCompensator.cpp @@ -53,7 +53,7 @@ SmallAreaInfillFlowCompensator::SmallAreaInfillFlowCompensator(const Slic3r::GCo } } - for (int i = 0; i < eLengths.size(); i++) { + for (size_t i = 0; i < eLengths.size(); i++) { if (i == 0) { if (!nearly_equal(eLengths[i], 0.0)) { throw Slic3r::InvalidArgument("First extrusion length for small area infill compensation model must be 0"); @@ -68,6 +68,12 @@ SmallAreaInfillFlowCompensator::SmallAreaInfillFlowCompensator(const Slic3r::GCo } } + for (size_t i = 1; i < flowComps.size(); ++i) { + if (flowComps[i] <= flowComps[i - 1]) { + throw Slic3r::InvalidArgument("Flow compensation factors must strictly increase with extrusion length"); + } + } + if (!flowComps.empty() && !nearly_equal(flowComps.back(), 1.0)) { throw Slic3r::InvalidArgument("Final compensation factor for small area infill flow compensation model must be 1.0"); }