From f24ca220d5dd57b4d7cfe444281511bd5c592270 Mon Sep 17 00:00:00 2001 From: Florens Wasserfall Date: Tue, 4 Apr 2017 16:25:00 +0200 Subject: [PATCH] fix potential endless loop when evaluating the spline --- xs/src/libslic3r/LayerHeightSpline.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xs/src/libslic3r/LayerHeightSpline.cpp b/xs/src/libslic3r/LayerHeightSpline.cpp index f2997a1d9..1e8da6cfe 100644 --- a/xs/src/libslic3r/LayerHeightSpline.cpp +++ b/xs/src/libslic3r/LayerHeightSpline.cpp @@ -158,15 +158,18 @@ std::vector LayerHeightSpline::getInterpolatedLayers() const coordf_t z = this->_original_layers[0]; coordf_t h; coordf_t h_diff = 0; + coordf_t last_h_diff = 0; coordf_t eps = 0.0001; while(z <= this->_object_height) { h = 0; + h_diff = 0; // find intersection between layer height and spline do { + last_h_diff = h_diff; h += h_diff/2; h = this->_layer_height_spline->evaluate(z+h); h_diff = this->_layer_height_spline->evaluate(z+h) - h; - } while(std::abs(h_diff) > eps); + } while(std::abs(h_diff) > eps && std::abs(h_diff - last_h_diff) > eps); z += h; layers.push_back(z); }