From e533d237f9961e73e3f2c5c59a0fe6be1b3b7083 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 4 Oct 2021 10:39:53 +0200 Subject: [PATCH] Manifold mesh may contain self-intersections, so we want to always allow fixing the mesh. This is a fix of a regression wrt. https://github.com/prusa3d/PrusaSlicer/releases/tag/version_2.4.0-alpha2 --- src/slic3r/GUI/GUI_ObjectList.cpp | 13 ++++++++----- src/slic3r/GUI/GUI_ObjectList.hpp | 3 +++ src/slic3r/GUI/Plater.cpp | 8 ++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index b941104270..1413af5533 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -377,10 +377,7 @@ void ObjectList::get_selection_indexes(std::vector& obj_idxs, std::vectorget_mesh_errors_count(vol_idx); + return obj_idx >= 0 ? (*m_objects)[obj_idx]->get_mesh_errors_count(vol_idx) : 0; } static std::string get_warning_icon_name(const TriangleMeshStats& stats) @@ -393,7 +390,7 @@ std::pair ObjectList::get_mesh_errors(const int obj_idx, const int errors = get_mesh_errors_count(obj_idx, vol_idx); if (errors == 0) - return { "", "" }; // hide tooltip + return { {}, {} }; // hide tooltip // Create tooltip string, if there are errors wxString tooltip = format_wxstr(_L_PLURAL("Auto-repaired %1$d error", "Auto-repaired %1$d errors", errors), errors) + ":\n"; @@ -4043,17 +4040,21 @@ 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 for (int i = int(obj_idxs.size())-1; i >= 0; --i) if (object(obj_idxs[i])->get_mesh_errors_count() == 0) obj_idxs.erase(obj_idxs.begin()+i); +#endif // FIX_THROUGH_NETFABB_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 for (int i = int(vol_idxs.size()) - 1; i >= 0; --i) if (obj->get_mesh_errors_count(vol_idxs[i]) == 0) vol_idxs.erase(vol_idxs.begin() + i); +#endif // FIX_THROUGH_NETFABB_ALWAYS for (int vol_idx : vol_idxs) model_names.push_back(obj->volumes[vol_idx]->name); } @@ -4106,8 +4107,10 @@ void ObjectList::fix_through_netfabb() if (vol_idxs.empty()) { int vol_idx{ -1 }; for (int obj_idx : obj_idxs) { +#if !FIX_THROUGH_NETFABB_ALWAYS if (object(obj_idx)->get_mesh_errors_count(vol_idx) == 0) continue; +#endif // FIX_THROUGH_NETFABB_ALWAYS if (!fix_and_update_progress(obj_idx, vol_idx, model_idx, progress_dlg, succes_models, failed_models)) break; model_idx++; diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 491bd26842..f168f6ff10 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -36,6 +36,9 @@ typedef double coordf_t; typedef std::pair t_layer_height_range; typedef std::map t_layer_config_ranges; +// Manifold mesh may contain self-intersections, so we want to always allow fixing the mesh. +#define FIX_THROUGH_NETFABB_ALWAYS 1 + namespace GUI { wxDECLARE_EVENT(EVT_OBJ_LIST_OBJECT_SELECT, SimpleEvent); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 074832d5a3..1f91b3589e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4536,6 +4536,11 @@ bool Plater::priv::can_fix_through_netfabb() const std::vector obj_idxs, vol_idxs; sidebar->obj_list()->get_selection_indexes(obj_idxs, vol_idxs); +#if FIX_THROUGH_NETFABB_ALWAYS + // Fixing always. + return ! obj_idxs.empty() || ! vol_idxs.empty(); +#else // FIX_THROUGH_NETFABB_ALWAYS + // Fixing only if the model is not manifold. if (vol_idxs.empty()) { for (auto obj_idx : obj_idxs) if (model.objects[obj_idx]->get_mesh_errors_count() > 0) @@ -4547,11 +4552,10 @@ bool Plater::priv::can_fix_through_netfabb() const for (auto vol_idx : vol_idxs) if (model.objects[obj_idx]->get_mesh_errors_count(vol_idx) > 0) return true; - return false; +#endif // FIX_THROUGH_NETFABB_ALWAYS } - bool Plater::priv::can_simplify() const { // is object for simplification selected