diff --git a/src/libslic3r/SLA/SLASupportTreeBuilder.cpp b/src/libslic3r/SLA/SLASupportTreeBuilder.cpp index 3fa9f3b984..2e0310ed8d 100644 --- a/src/libslic3r/SLA/SLASupportTreeBuilder.cpp +++ b/src/libslic3r/SLA/SLASupportTreeBuilder.cpp @@ -171,6 +171,9 @@ Head::Head(double r_big_mm, , width_mm(length_mm) , penetration_mm(penetration) { + assert(width_mm > 0.); + assert(r_back_mm > 0.); + assert(r_pin_mm > 0.); // We create two spheres which will be connected with a robe that fits // both circles perfectly. diff --git a/src/libslic3r/SLA/SLASupportTreeBuilder.hpp b/src/libslic3r/SLA/SLASupportTreeBuilder.hpp index 95fcdcc326..c0d9f04c0f 100644 --- a/src/libslic3r/SLA/SLASupportTreeBuilder.hpp +++ b/src/libslic3r/SLA/SLASupportTreeBuilder.hpp @@ -311,7 +311,7 @@ public: if (m_pillars.capacity() < m_heads.size()) m_pillars.reserve(m_heads.size() * 10); - assert(headid >= 0 && headid < m_head_indices.size()); + assert(headid >= 0 && size_t(headid) < m_head_indices.size()); Head &head = m_heads[m_head_indices[size_t(headid)]]; m_pillars.emplace_back(head, std::forward(args)...); @@ -328,7 +328,7 @@ public: void add_pillar_base(long pid, double baseheight = 3, double radius = 2) { std::lock_guard lk(m_mutex); - assert(pid >= 0 && pid < m_pillars.size()); + assert(pid >= 0 && size_t(pid) < m_pillars.size()); m_pillars[size_t(pid)].add_base(baseheight, radius); } @@ -398,7 +398,7 @@ public: const Bridge& add_bridge(long headid, const Vec3d &endp, size_t s = 45) { std::lock_guard lk(m_mutex); - assert(headid >= 0 && headid < m_head_indices.size()); + assert(headid >= 0 && size_t(headid) < m_head_indices.size()); Head &h = m_heads[m_head_indices[size_t(headid)]]; m_bridges.emplace_back(h.junction_point(), endp, h.r_back_mm, s); diff --git a/src/libslic3r/SLA/SLASupportTreeBuildsteps.cpp b/src/libslic3r/SLA/SLASupportTreeBuildsteps.cpp index 60e8f15b79..392a963e12 100644 --- a/src/libslic3r/SLA/SLASupportTreeBuildsteps.cpp +++ b/src/libslic3r/SLA/SLASupportTreeBuildsteps.cpp @@ -1096,6 +1096,11 @@ void SupportTreeBuildsteps::routing_to_model() double dist = distance(endp, hitp) + m_cfg.head_penetration_mm; double w = dist - 2 * head.r_pin_mm - head.r_back_mm; + if (w < 0.) { + BOOST_LOG_TRIVIAL(error) << "Pinhead width is negative!"; + w = 0.; + } + Head tailhead(head.r_back_mm, head.r_pin_mm, w, @@ -1348,7 +1353,7 @@ void SupportTreeBuildsteps::routing_headless() m_thr(); const auto R = double(m_support_pts[i].head_front_radius); - const double HWIDTH_MM = R/3; + const double HWIDTH_MM = m_cfg.head_penetration_mm; // Exact support position Vec3d sph = m_support_pts[i].pos.cast(); diff --git a/tests/sla_print/sla_print_tests_main.cpp b/tests/sla_print/sla_print_tests_main.cpp index 5952e55454..bd2475f411 100644 --- a/tests/sla_print/sla_print_tests_main.cpp +++ b/tests/sla_print/sla_print_tests_main.cpp @@ -260,7 +260,7 @@ void test_support_model_collision( // Set head penetration to a small negative value which should ensure that // the supports will not touch the model body. - supportcfg.head_penetration_mm = -1.; // 1 mm should be more than enough + supportcfg.head_penetration_mm = -0.1; test_supports(obj_filename, supportcfg, byproducts); @@ -277,6 +277,7 @@ void test_support_model_collision( const ExPolygons &mod_slice = byproducts.model_slices[n]; Polygons intersections = intersection(sup_slice, mod_slice); + notouch = notouch && intersections.empty(); }