Meshfix integration into GUI

This commit is contained in:
PavelMikus 2022-05-31 17:33:46 +02:00 committed by Lukas Matena
parent a1143ab26e
commit 20c91aa48e
50 changed files with 16665 additions and 29 deletions
src/slic3r/GUI

View file

@ -28,6 +28,7 @@
#include <wx/numformatter.h>
#include "slic3r/Utils/FixModelByWin10.hpp"
#include "slic3r/Utils/FixModelByMeshFix.hpp"
#ifdef __WXMSW__
#include "wx/uiaction.h"
@ -916,7 +917,7 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
{
if (is_windows10() && m_objects_model->HasWarningIcon(item) &&
mouse_pos.x > 2 * wxGetApp().em_unit() && mouse_pos.x < 4 * wxGetApp().em_unit())
fix_through_netfabb();
repair_mesh(rmaNetfabb);
else if (evt_context_menu)
show_context_menu(evt_context_menu); // show context menu for "Name" column too
}
@ -4031,7 +4032,7 @@ void ObjectList::rename_item()
update_name_in_model(item);
}
void ObjectList::fix_through_netfabb()
void ObjectList::repair_mesh(ObjectList::REPAIR_MESH_ALG alg)
{
// Do not fix anything when a gizmo is open. There might be issues with updates
// and what is worse, the snapshot time would refer to the internal stack.
@ -4051,28 +4052,28 @@ void ObjectList::fix_through_netfabb()
// clear selections from the non-broken models if any exists
// and than fill names of models to repairing
if (vol_idxs.empty()) {
#if !FIX_THROUGH_NETFABB_ALWAYS
#if !FIX_MESH_ALWAYS
for (int i = int(obj_idxs.size())-1; i >= 0; --i)
if (object(obj_idxs[i])->get_repaired_errors_count() == 0)
obj_idxs.erase(obj_idxs.begin()+i);
#endif // FIX_THROUGH_NETFABB_ALWAYS
#endif // FIX_MESH_ALWAYS
for (int obj_idx : obj_idxs)
model_names.push_back(object(obj_idx)->name);
}
else {
ModelObject* obj = object(obj_idxs.front());
#if !FIX_THROUGH_NETFABB_ALWAYS
#if !FIX_MESH_ALWAYS
for (int i = int(vol_idxs.size()) - 1; i >= 0; --i)
if (obj->get_repaired_errors_count(vol_idxs[i]) == 0)
vol_idxs.erase(vol_idxs.begin() + i);
#endif // FIX_THROUGH_NETFABB_ALWAYS
#endif // FIX_MESH_ALWAYS
for (int vol_idx : vol_idxs)
model_names.push_back(obj->volumes[vol_idx]->name);
}
auto plater = wxGetApp().plater();
auto fix_and_update_progress = [this, plater, model_names](const int obj_idx, const int vol_idx,
auto fix_and_update_progress = [this, plater, model_names, alg](const int obj_idx, const int vol_idx,
int model_idx,
wxProgressDialog& progress_dlg,
std::vector<std::string>& succes_models,
@ -4091,8 +4092,19 @@ void ObjectList::fix_through_netfabb()
plater->clear_before_change_mesh(obj_idx);
std::string res;
if (!fix_model_by_win10_sdk_gui(*(object(obj_idx)), vol_idx, progress_dlg, msg, res))
return false;
bool result = false;
switch (alg) {
case rmaNetfabb:
result = fix_model_by_win10_sdk_gui(*(object(obj_idx)), vol_idx, progress_dlg, msg, res);
break;
case rmaMeshfix:
result = fix_model_by_meshfix(*(object(obj_idx)), vol_idx, progress_dlg, msg, res);
break;
default:
break;
}
if (!result) return false;
wxGetApp().plater()->changed_mesh(obj_idx);
plater->changed_mesh(obj_idx);
@ -4108,19 +4120,19 @@ void ObjectList::fix_through_netfabb()
return true;
};
Plater::TakeSnapshot snapshot(plater, _L("Fix through NetFabb"));
Plater::TakeSnapshot snapshot(plater, _L("Repair model mesh"));
// Open a progress dialog.
wxProgressDialog progress_dlg(_L("Fixing through NetFabb"), "", 100, find_toplevel_parent(plater),
wxProgressDialog progress_dlg(_L("Repair model mesh"), "", 100, find_toplevel_parent(plater),
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
int model_idx{ 0 };
if (vol_idxs.empty()) {
int vol_idx{ -1 };
for (int obj_idx : obj_idxs) {
#if !FIX_THROUGH_NETFABB_ALWAYS
#if !FIX_MESH_ALWAYS
if (object(obj_idx)->get_repaired_errors_count(vol_idx) == 0)
continue;
#endif // FIX_THROUGH_NETFABB_ALWAYS
#endif // FIX_MESH_ALWAYS
if (!fix_and_update_progress(obj_idx, vol_idx, model_idx, progress_dlg, succes_models, failed_models))
break;
model_idx++;
@ -4153,7 +4165,7 @@ void ObjectList::fix_through_netfabb()
}
if (msg.IsEmpty())
msg = _L("Repairing was canceled");
plater->get_notification_manager()->push_notification(NotificationType::NetfabbFinished, NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel, boost::nowide::narrow(msg));
plater->get_notification_manager()->push_notification(NotificationType::RepairMeshFinished, NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel, boost::nowide::narrow(msg));
}
void ObjectList::simplify()