From 41a5117c933bdd1a479026f1f0efac96bd4fdf57 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Mon, 27 Nov 2023 14:39:05 +0800 Subject: [PATCH] ENH: Resolve non manifold edges by fixing model interfaces Jira: STUDIO-5124 Change-Id: I7ea86be44acb80b6c4762a76208b4a031acd0b27 --- src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp | 32 +++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp index dcc593498..24ec37d6e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp @@ -16,7 +16,7 @@ #include "libslic3r/AppConfig.hpp" #include - +#include "FixModelByWin10.hpp" namespace Slic3r { namespace GUI { @@ -912,6 +912,36 @@ void GLGizmoAdvancedCut::perform_cut(const Selection& selection) const ModelObjectPtrs &new_objects = cut_by_contour ? cut.perform_by_contour(m_part_selection->get_cut_parts(), dowels_count) : cut_with_groove ? cut.perform_with_groove(m_groove, m_rotate_matrix) : cut.perform_with_plane(); + // fix_non_manifold_edges +#ifdef HAS_WIN10SDK + if (is_windows10()) { + for (size_t i = 0; i < new_objects.size(); i++) { + for (size_t j = 0; j < new_objects[i]->volumes.size(); j++) { + if (its_num_open_edges(new_objects[i]->volumes[j]->mesh().its) > 0) { + // model_name + std::vector succes_models; + // model_name failing reason + std::vector> failed_models; + auto plater = wxGetApp().plater(); + auto fix_and_update_progress = [this, plater](ModelObject *model_object, const int vol_idx, const string &model_name, ProgressDialog &progress_dlg, + std::vector &succes_models, std::vector> &failed_models) { + wxString msg = _L("Repairing model object"); + msg += ": " + from_u8(model_name) + "\n"; + std::string res; + if (!fix_model_by_win10_sdk_gui(*model_object, vol_idx, progress_dlg, msg, res)) return false; + return true; + }; + ProgressDialog progress_dlg(_L("Repairing model object"), "", 100, find_toplevel_parent(plater), wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT, true); + + auto model_name = new_objects[i]->name; + if (!fix_and_update_progress(new_objects[i], j, model_name, progress_dlg, succes_models, failed_models)) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "run fix_and_update_progress error"; + }; + }; + } + } + } + #endif // set offset for new_objects // save cut_id to post update synchronization