From fab3025107f3a0e3ec9db01f579e1457c6d9de12 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 4 Feb 2019 10:56:49 +0100 Subject: [PATCH] SLA support points - minor adjustments --- src/libslic3r/SLA/SLAAutoSupports.cpp | 15 +++++++++------ src/slic3r/GUI/GLGizmo.cpp | 13 +++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/SLA/SLAAutoSupports.cpp b/src/libslic3r/SLA/SLAAutoSupports.cpp index c853e8756..ddf280471 100644 --- a/src/libslic3r/SLA/SLAAutoSupports.cpp +++ b/src/libslic3r/SLA/SLAAutoSupports.cpp @@ -111,8 +111,11 @@ void SLAAutoSupports::process(const std::vector& slices, const std:: m_structures_new.back().structures_below.push_back(&s); coord_t centroids_dist = (bottom->contour.centroid() - polygon.contour.centroid()).norm(); - float mult = std::min(1.f, 1.f - std::min(1.f, (1600.f * layer_height) * (float)(centroids_dist * centroids_dist) / (float)bottom->area())); - s.supports_force *= mult; + + // Penalization resulting from centroid offset: + s.supports_force *= std::min(1.f, 1.f - std::min(1.f, (1600.f * layer_height) * (float)(centroids_dist * centroids_dist) / (float)bottom->area())); + + // Penalization resulting from increasing polygon area: s.supports_force *= std::min(1.f, 20.f * ((float)bottom->area() / (float)polygon.area())); } } @@ -165,10 +168,10 @@ void SLAAutoSupports::process(const std::vector& slices, const std:: } e = diff_ex(ExPolygons{*s.polygon}, e); + + // Penalization resulting from large diff from the last layer: s.supports_force /= std::max(1., (layer_height / 0.3f) * (e_area / (s.polygon->area()*SCALING_FACTOR*SCALING_FACTOR))); - - - + if ( (s.polygon->area() * pow(SCALING_FACTOR, 2)) * m_config.tear_pressure > s.supports_force) { ExPolygons::iterator largest_it = std::max_element(e.begin(), e.end(), [](const ExPolygon& a, const ExPolygon& b) { return a.area() < b.area(); }); if (!e.empty()) @@ -215,7 +218,7 @@ void SLAAutoSupports::uniformly_cover(const ExPolygon& island, Structure& struct std::vector island_new_points; const BoundingBox& bb = get_extents(island); - const int refused_limit = 30; + const int refused_limit = 30 * ((float)bb.size()(0)*bb.size()(1) / (float)island.area()); int refused_points = 0; while (refused_points < refused_limit) { Point out; diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index 6522287b5..4b0b917e9 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -1941,6 +1941,7 @@ void GLGizmoSlaSupports::update_mesh() // we'll now reload Grabbers (selection might have changed): m_grabbers.clear(); + m_editing_mode_cache = m_model_object->sla_support_points; for (const sla::SupportPoint& point : m_editing_mode_cache) { m_grabbers.push_back(Grabber()); @@ -2044,7 +2045,7 @@ void GLGizmoSlaSupports::delete_current_grabber(bool delete_all) // wxGetApp().plater()->reslice(); } } - m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); + //m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); } void GLGizmoSlaSupports::on_update(const UpdateData& data, const GLCanvas3D::Selection& selection) @@ -2203,17 +2204,17 @@ RENDER_AGAIN: if (remove_all_points) { - force_refresh = true; + force_refresh = false; + m_parent.reload_scene(true); delete_current_grabber(true); - /*if (first_run) { + if (first_run) { first_run = false; goto RENDER_AGAIN; - }*/ + } } - if (force_refresh) { + if (force_refresh) m_parent.reload_scene(true); - } } #endif // ENABLE_IMGUI