From a7eda7cc8e26601fe7efc25a65e805fb0a017214 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 26 Jan 2023 21:26:31 +0100 Subject: [PATCH 1/2] Fixed is_nil(size_t) when checking out-of-range element: the behaviour should math get_at, which returns first element in case the index is out of range. --- src/libslic3r/Config.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 23be26ee71..c0c7abba0d 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -615,7 +615,7 @@ public: static double nil_value() { return std::numeric_limits::quiet_NaN(); } // A scalar is nil, or all values of a vector are nil. bool is_nil() const override { for (auto v : this->values) if (! std::isnan(v)) return false; return true; } - bool is_nil(size_t idx) const override { return std::isnan(this->values[idx]); } + bool is_nil(size_t idx) const override { return std::isnan(this->values[idx < values.size() ? idx : 0]); } std::string serialize() const override { @@ -1092,7 +1092,7 @@ public: static FloatOrPercent nil_value() { return { std::numeric_limits::quiet_NaN(), false }; } // A scalar is nil, or all values of a vector are nil. bool is_nil() const override { for (auto v : this->values) if (! std::isnan(v.value)) return false; return true; } - bool is_nil(size_t idx) const override { return std::isnan(this->values[idx].value); } + bool is_nil(size_t idx) const override { return std::isnan(this->values[idx < values.size() ? idx : 0].value); } std::string serialize() const override { @@ -1404,7 +1404,7 @@ public: static unsigned char nil_value() { return std::numeric_limits::max(); } // A scalar is nil, or all values of a vector are nil. bool is_nil() const override { for (auto v : this->values) if (v != nil_value()) return false; return true; } - bool is_nil(size_t idx) const override { return this->values[idx] == nil_value(); } + bool is_nil(size_t idx) const override { return this->values[idx < values.size() ? idx : 0] == nil_value(); } bool& get_at(size_t i) { assert(! this->values.empty()); From 9f9bca5cd0004b7169e6220a4506aea2ad5cbec3 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 25 Jan 2023 15:43:56 +0100 Subject: [PATCH 2/2] Fix pad struts not connecting to model --- src/libslic3r/SLA/SupportTree.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/SLA/SupportTree.cpp b/src/libslic3r/SLA/SupportTree.cpp index cfafdf7e97..3de05261a3 100644 --- a/src/libslic3r/SLA/SupportTree.cpp +++ b/src/libslic3r/SLA/SupportTree.cpp @@ -68,13 +68,14 @@ indexed_triangle_set create_pad(const SupportableMesh &sm, const indexed_triangle_set &support_mesh, const JobController &ctl) { + constexpr float PadSamplingLH = 0.1f; ExPolygons model_contours; // This will store the base plate of the pad. - double pad_h = sm.pad_cfg.full_height(); - - float zstart = ground_level(sm); - float zend = zstart + float(pad_h + EPSILON); - auto heights = grid(zstart, zend, 0.1f); + double pad_h = sm.pad_cfg.full_height(); + auto gndlvl = float(ground_level(sm)); + float zstart = gndlvl - bool(sm.pad_cfg.embed_object) * sm.pad_cfg.wall_thickness_mm; + float zend = zstart + float(pad_h + PadSamplingLH + EPSILON); + auto heights = grid(zstart, zend, PadSamplingLH); if (!sm.cfg.enabled || sm.pad_cfg.embed_object) { // No support (thus no elevation) or zero elevation mode @@ -91,7 +92,7 @@ indexed_triangle_set create_pad(const SupportableMesh &sm, indexed_triangle_set out; create_pad(sup_contours, model_contours, out, sm.pad_cfg); - Vec3f offs{.0f, .0f, zstart}; + Vec3f offs{.0f, .0f, gndlvl}; for (auto &p : out.vertices) p += offs; its_merge_vertices(out);