From 0e4d49452f84d46b34f2e027212a214e81766638 Mon Sep 17 00:00:00 2001 From: Pavulon87 Date: Sun, 2 Aug 2020 18:57:20 +0200 Subject: [PATCH] fix adjust_layer_height_profile for high z_step GLCanvas3D.cpp from a work by @Pavulon87 --- src/libslic3r/Slicing.cpp | 2 +- src/libslic3r/Slicing.hpp | 3 ++- src/slic3r/GUI/GLCanvas3D.cpp | 6 ++++-- src/slic3r/GUI/GLCanvas3D.hpp | 2 +- src/slic3r/GUI/Tab.cpp | 14 ++------------ 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/libslic3r/Slicing.cpp b/src/libslic3r/Slicing.cpp index 7d99b6604..f45984bd5 100644 --- a/src/libslic3r/Slicing.cpp +++ b/src/libslic3r/Slicing.cpp @@ -24,7 +24,7 @@ namespace Slic3r static const coordf_t MIN_LAYER_HEIGHT = 0.01; static const coordf_t MIN_LAYER_HEIGHT_DEFAULT = 0.07; // fields are with 8-number precision after the dot -inline coordf_t check_z_step(const coordf_t val, const coordf_t z_step) { +coordf_t check_z_step(const coordf_t val, const coordf_t z_step) { if (z_step <= EPSILON) return val; uint64_t valint = uint64_t(val * 100000000. + 0.1); uint64_t stepint = uint64_t(z_step * 100000000. + 0.1); diff --git a/src/libslic3r/Slicing.hpp b/src/libslic3r/Slicing.hpp index ce732da38..1dff6aed3 100644 --- a/src/libslic3r/Slicing.hpp +++ b/src/libslic3r/Slicing.hpp @@ -20,7 +20,8 @@ class PrintConfig; class PrintObjectConfig; class ModelObject; -coordf_t check_z_step(const coordf_t val,const coordf_t z_step); +// little function that return val as a multiple of z_step if z_step is not == 0 +extern coordf_t check_z_step(const coordf_t val,const coordf_t z_step); // Parameters to guide object slicing and support generation. // The slicing parameters account for a raft and whether the 1st object layer is printed with a normal or a bridging flow diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 33cf264a2..73ce1f98d 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -141,7 +141,6 @@ GLCanvas3D::LayersEditing::LayersEditing() , m_adaptive_quality(0.5f) , state(Unknown) , band_width(2.0f) - , strength(0.005f) , last_object_id(-1) , last_z(0.0f) , last_action(LAYER_HEIGHT_EDIT_ACTION_INCREASE) @@ -534,7 +533,10 @@ void GLCanvas3D::LayersEditing::adjust_layer_height_profile() { this->update_slicing_parameters(); PrintObject::update_layer_height_profile(*m_model_object, *m_slicing_parameters, m_layer_height_profile); - Slic3r::adjust_layer_height_profile(*m_slicing_parameters, m_layer_height_profile, this->last_z, this->strength, this->band_width, this->last_action); + //update strength + float strength = 0.005f; + if (m_slicing_parameters->z_step > EPSILON) strength = (float)Slic3r::check_z_step(std::max(0.005, m_slicing_parameters->z_step), m_slicing_parameters->z_step); + Slic3r::adjust_layer_height_profile(*m_slicing_parameters, m_layer_height_profile, this->last_z, strength, this->band_width, this->last_action); m_layer_height_profile_modified = true; m_layers_texture.valid = false; } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 11a6e9200..cfe835e91 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -204,7 +204,7 @@ private: public: EState state; float band_width; - float strength; + //float strength; int last_object_id; float last_z; LayerHeightEditActionType last_action; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index aabd10055..7818f3ff7 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -45,16 +45,6 @@ namespace GUI { wxDEFINE_EVENT(EVT_TAB_VALUE_CHANGED, wxCommandEvent); wxDEFINE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent); -//same as the slicing.cpp method, but it's easier to redefine it here -// maybe i should have written it in the header. -inline coordf_t check_z_step_temp(coordf_t val, coordf_t z_step) { - if (z_step <= EPSILON) return val; - uint64_t valint = uint64_t(val * 100000000. + 0.1); - uint64_t stepint = uint64_t(z_step * 100000000. + 0.1); - return (((valint + (stepint / 2)) / stepint) * stepint) / 100000000.; - //return int((val + z_step * 0.5) / z_step) * z_step; -} - Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) : m_parent(parent), m_title(title), m_type(type) { @@ -2600,7 +2590,7 @@ void TabPrinter::update_fff() if (min_layer_height[i] / z_step != 0) { if(!has_changed ) new_conf = *m_config; - new_conf.option("min_layer_height")->values[i] = std::max(z_step, check_z_step_temp(new_conf.option("min_layer_height")->values[i], z_step)); + new_conf.option("min_layer_height")->values[i] = std::max(z_step, Slic3r::check_z_step(new_conf.option("min_layer_height")->values[i], z_step)); has_changed = true; } const std::vector& max_layer_height = m_config->option("max_layer_height")->values; @@ -2608,7 +2598,7 @@ void TabPrinter::update_fff() if (max_layer_height[i] / z_step != 0) { if (!has_changed) new_conf = *m_config; - new_conf.option("max_layer_height")->values[i] = std::max(z_step, check_z_step_temp(new_conf.option("max_layer_height")->values[i], z_step)); + new_conf.option("max_layer_height")->values[i] = std::max(z_step, Slic3r::check_z_step(new_conf.option("max_layer_height")->values[i], z_step)); has_changed = true; } if (has_changed) {