ENH: Resolve non manifold edges by fixing model interfaces

Jira: STUDIO-5124
Change-Id: I7ea86be44acb80b6c4762a76208b4a031acd0b27
This commit is contained in:
zhou.xu 2023-11-27 14:39:05 +08:00 committed by Lane.Wei
parent ffb4326e8e
commit 41a5117c93

View File

@ -16,7 +16,7 @@
#include "libslic3r/AppConfig.hpp" #include "libslic3r/AppConfig.hpp"
#include <imgui/imgui_internal.h> #include <imgui/imgui_internal.h>
#include "FixModelByWin10.hpp"
namespace Slic3r { namespace Slic3r {
namespace GUI { 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) : 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_with_groove ? cut.perform_with_groove(m_groove, m_rotate_matrix) :
cut.perform_with_plane(); 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<std::string> succes_models;
// model_name failing reason
std::vector<std::pair<std::string, std::string>> 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<std::string> &succes_models, std::vector<std::pair<std::string, std::string>> &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 // set offset for new_objects
// save cut_id to post update synchronization // save cut_id to post update synchronization