From 8be3d074fd5bc0449c1c968f6e63c294008973bb Mon Sep 17 00:00:00 2001 From: Lukas Matena <lukasmatena@seznam.cz> Date: Thu, 20 Feb 2020 13:23:25 +0100 Subject: [PATCH] Fix of wipe into object The bug was introduced in 15eedef. lower_bound_by_predicate implementation returns first item that does not satisfy the predicate, not last item that does. --- src/libslic3r/Print.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 4f9f9ad1e..a23922426 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -150,15 +150,15 @@ public: Layer* get_layer(int idx) { return m_layers[idx]; } // Get a layer exactly at print_z. const Layer* get_layer_at_printz(coordf_t print_z) const { - auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; }); + auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; }); return (it == m_layers.end() || (*it)->print_z != print_z) ? nullptr : *it; } Layer* get_layer_at_printz(coordf_t print_z) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z)); } // Get a layer approximately at print_z. const Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const { - coordf_t limit = print_z + epsilon; - auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; }); - return (it == m_layers.end() || (*it)->print_z < print_z - epsilon) ? nullptr : *it; + coordf_t limit = print_z - epsilon; + auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; }); + return (it == m_layers.end() || (*it)->print_z > print_z + epsilon) ? nullptr : *it; } Layer* get_layer_at_printz(coordf_t print_z, coordf_t epsilon) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z, epsilon)); }