From 8e956f68c3bf3dfe2dd7b41e40fe593d3199428c Mon Sep 17 00:00:00 2001 From: Filip Sykala - NTB T15p Date: Tue, 14 Jan 2025 10:49:13 +0100 Subject: [PATCH] Remove duplication of permanent points --- src/libslic3r/SLA/SupportPointGenerator.cpp | 9 ++++++++- src/libslic3r/SLA/SupportPointGenerator.hpp | 3 +++ src/libslic3r/SLAPrintSteps.cpp | 3 ++- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 11 +---------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/SLA/SupportPointGenerator.cpp b/src/libslic3r/SLA/SupportPointGenerator.cpp index d22dbfa73a..dcd67a1204 100644 --- a/src/libslic3r/SLA/SupportPointGenerator.cpp +++ b/src/libslic3r/SLA/SupportPointGenerator.cpp @@ -1118,7 +1118,9 @@ void copy_permanent_supports(NearPoints& near_points, const PermanentSupports& s /* SupportPoint */ *support.point_it, /* position_on_layer */ support.layer_position, /* radius_curve_index */ 0, // before support point - earlier influence on point distribution - /* current_radius */ calc_influence_radius(fabs(support.point_it->pos.z() - print_z), config) + /* current_radius */ calc_influence_radius(fabs(support.point_it->pos.z() - print_z), config), + /* active_in_part */ true, + /* is_permanent */ true }); // NOTE: increment index globaly @@ -1192,6 +1194,7 @@ LayerSupportPoints Slic3r::sla::generate_support_points( NearPoints near_points = create_near_points(prev_layer_parts, part, prev_grids); remove_supports_out_of_part(near_points, part, config); if (!part.peninsulas.empty()) { + // only get copy of points do not modify permanent_index Points permanent = get_permanents(permanent_supports, permanent_index, layer_id, part_id); support_peninsulas(part.peninsulas, near_points, layer.print_z, permanent, config); } @@ -1209,6 +1212,10 @@ LayerSupportPoints Slic3r::sla::generate_support_points( if (old_status_int < status_int) statusfn(status_int); } + // Remove permanent supports from result + // To preserve permanent 3d position it is necessary to append points after move_on_mesh_surface + result.erase(std::remove_if(result.begin(), result.end(), + [](const LayerSupportPoint &p) { return p.is_permanent; }), result.end()); return result; } diff --git a/src/libslic3r/SLA/SupportPointGenerator.hpp b/src/libslic3r/SLA/SupportPointGenerator.hpp index 98adbbcf2c..e685a5dec0 100644 --- a/src/libslic3r/SLA/SupportPointGenerator.hpp +++ b/src/libslic3r/SLA/SupportPointGenerator.hpp @@ -126,6 +126,9 @@ struct LayerSupportPoint: public SupportPoint // Flagged false when no part on layer in Radius 'r' around support point // Tool to support overlapped overhang area multiple times bool active_in_part = true; + + // When true support point position is not generated by algorithm + bool is_permanent = false; }; using LayerSupportPoints = std::vector; diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index 9fabd8136e..24b65135e5 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -725,7 +725,8 @@ void SLAPrint::Steps::support_points(SLAPrintObject &po) SupportPoints support_points = move_on_mesh_surface(layer_support_points, emesh, allowed_move, cancel); - // Naive implementation only append permanent supports to the result + // Generator count with permanent support positions but do not convert to LayerSupportPoints. + // To preserve permanent 3d position it is necessary to append points after move_on_mesh_surface support_points.insert(support_points.end(), data.permanent_supports.begin(), data.permanent_supports.end()); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index ea7619c104..85409fcd23 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -1362,19 +1362,10 @@ void GLGizmoSlaSupports::get_data_from_backend() void GLGizmoSlaSupports::auto_generate() { - //wxMessageDialog dlg(GUI::wxGetApp().plater(), - MessageDialog dlg(GUI::wxGetApp().plater(), - _L("Autogeneration with manually edited points is inperfect but preserve wanted postion of supports.") + "\n\n" + - _L("Do you want to remove manually edited points?") + "\n", - _L("Warning"), wxICON_WARNING | wxYES | wxNO); - ModelObject* mo = m_c->selection_info()->model_object(); - if (mo->sla_points_status == sla::PointsStatus::UserModified && - dlg.ShowModal() == wxID_YES) { - mo->sla_support_points.clear(); - } Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Autogenerate support points")); wxGetApp().CallAfter([this]() { reslice_until_step( m_show_support_structure ? slaposPad : slaposSupportPoints); }); + ModelObject* mo = m_c->selection_info()->model_object(); mo->sla_points_status = sla::PointsStatus::Generating; }