diff --git a/xs/src/libslic3r/LayerHeightSpline.cpp b/xs/src/libslic3r/LayerHeightSpline.cpp index d5c13f5e8..5fe16e2f9 100644 --- a/xs/src/libslic3r/LayerHeightSpline.cpp +++ b/xs/src/libslic3r/LayerHeightSpline.cpp @@ -170,9 +170,18 @@ bool LayerHeightSpline::_updateBSpline() bool result = false; //TODO: exception if not enough points? - this->_layer_height_spline.reset(new BSpline(&this->_layers[1], - this->_layers.size()-1, - &this->_layer_heights[1], + // copy layer vectors and duplicate a datapoint at the front / end to achieve correct boundary conditions + this->_spline_layers = this->_layers; + this->_spline_layers[0] = 0; + this->_spline_layers.push_back(this->_spline_layers.back()+1); + + this->_spline_layer_heights = this->_layer_heights; + this->_spline_layer_heights[0] = this->_spline_layer_heights[1]; // override fixed first layer height with first "real" layer + this->_spline_layer_heights.push_back(this->_spline_layer_heights.back()); + + this->_layer_height_spline.reset(new BSpline(&this->_spline_layers[0], + this->_spline_layers.size(), + &this->_spline_layer_heights[0], 0, 1, 0) diff --git a/xs/src/libslic3r/LayerHeightSpline.hpp b/xs/src/libslic3r/LayerHeightSpline.hpp index 8fb554cbb..214f2466c 100644 --- a/xs/src/libslic3r/LayerHeightSpline.hpp +++ b/xs/src/libslic3r/LayerHeightSpline.hpp @@ -33,6 +33,8 @@ class LayerHeightSpline bool _layer_heights_updated; std::vector _layers; std::vector _layer_heights; + std::vector _spline_layers; + std::vector _spline_layer_heights; std::unique_ptr> _layer_height_spline; };