From 9e32a00efc630df2c08a6a0aba7dc7513a22e099 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 10 Aug 2021 15:17:35 +0200 Subject: [PATCH] Fix of incorrect volume scaling after fix by Netfabb, see the comment in the code as to why it happened --- src/slic3r/Utils/FixModelByWin10.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/slic3r/Utils/FixModelByWin10.cpp b/src/slic3r/Utils/FixModelByWin10.cpp index cfe8b68b3..a3689d927 100644 --- a/src/slic3r/Utils/FixModelByWin10.cpp +++ b/src/slic3r/Utils/FixModelByWin10.cpp @@ -37,7 +37,7 @@ #include "../GUI/I18N.hpp" #include "../GUI/MsgDialog.hpp" #include "../GUI/GUI_App.hpp" -#include "../GUI/Mainframe.hpp" +#include "../GUI/MainFrame.hpp" #include #include @@ -364,9 +364,17 @@ void fix_model_by_win10_sdk_gui(ModelObject &model_object, int volume_idx) boost::filesystem::path path_src = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); path_src += ".3mf"; Model model; - ModelObject *model_object = model.add_object(); - model_object->add_volume(*volumes[ivolume]); - model_object->add_instance(); + ModelObject *mo = model.add_object(); + mo->add_volume(*volumes[ivolume]); + + // We are about to save a 3mf, fix it by netfabb and load the fixed 3mf back. + // store_3mf currently bakes the volume transformation into the mesh itself. + // If we then loaded the repaired 3mf and pushed the mesh into the original ModelVolume + // (which remembers the matrix the whole time), the transformation would be used twice. + // We will therefore set the volume transform on the dummy ModelVolume to identity. + mo->volumes.back()->set_transformation(Geometry::Transformation()); + + mo->add_instance(); if (!Slic3r::store_3mf(path_src.string().c_str(), &model, nullptr, false, nullptr, false)) { boost::filesystem::remove(path_src); throw Slic3r::RuntimeError(L("Export of a temporary 3mf file failed"));