From 2c6431218eef64fa4c539378cd6b03813061f061 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 7 Jul 2022 15:55:05 +0200 Subject: [PATCH 01/17] Add arrange parameter to set min distance from bed implements FR #8442 --- src/slic3r/GUI/GLCanvas3D.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 66759f4c7..367a0e806 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1111,12 +1111,21 @@ void GLCanvas3D::load_arrange_settings() std::string dist_fff_str = wxGetApp().app_config->get("arrange", "min_object_distance_fff"); + std::string dist_bed_fff_str = + wxGetApp().app_config->get("arrange", "min_bed_distance_fff"); + std::string dist_fff_seq_print_str = wxGetApp().app_config->get("arrange", "min_object_distance_fff_seq_print"); + std::string dist_bed_fff_seq_print_str = + wxGetApp().app_config->get("arrange", "min_bed_distance_fff_seq_print"); + std::string dist_sla_str = wxGetApp().app_config->get("arrange", "min_object_distance_sla"); + std::string dist_bed_sla_str = + wxGetApp().app_config->get("arrange", "min_bed_distance_sla"); + std::string en_rot_fff_str = wxGetApp().app_config->get("arrange", "enable_rotation_fff"); @@ -1129,12 +1138,21 @@ void GLCanvas3D::load_arrange_settings() if (!dist_fff_str.empty()) m_arrange_settings_fff.distance = string_to_float_decimal_point(dist_fff_str); + if (!dist_bed_fff_str.empty()) + m_arrange_settings_fff.distance_from_bed = string_to_float_decimal_point(dist_bed_fff_str); + if (!dist_fff_seq_print_str.empty()) m_arrange_settings_fff_seq_print.distance = string_to_float_decimal_point(dist_fff_seq_print_str); + if (!dist_bed_fff_seq_print_str.empty()) + m_arrange_settings_fff_seq_print.distance_from_bed = string_to_float_decimal_point(dist_bed_fff_seq_print_str); + if (!dist_sla_str.empty()) m_arrange_settings_sla.distance = string_to_float_decimal_point(dist_sla_str); + if (!dist_bed_sla_str.empty()) + m_arrange_settings_sla.distance_from_bed = string_to_float_decimal_point(dist_bed_sla_str); + if (!en_rot_fff_str.empty()) m_arrange_settings_fff.enable_rotation = (en_rot_fff_str == "1" || en_rot_fff_str == "yes"); @@ -4525,11 +4543,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) bool settings_changed = false; float dist_min = 0.f; - std::string dist_key = "min_object_distance", rot_key = "enable_rotation"; + float dist_bed_min = 0.f; + std::string dist_key = "min_object_distance"; + std::string dist_bed_key = "min_bed_distance"; + std::string rot_key = "enable_rotation"; std::string postfix; if (ptech == ptSLA) { - dist_min = 0.f; postfix = "_sla"; } else if (ptech == ptFFF) { auto co_opt = m_config->option("complete_objects"); @@ -4543,7 +4563,8 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) } dist_key += postfix; - rot_key += postfix; + dist_bed_key += postfix; + rot_key += postfix; imgui->text(GUI::format_wxstr(_L("Press %1%left mouse button to enter the exact value"), shortkey_ctrl_prefix())); @@ -4554,6 +4575,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) settings_changed = true; } + if (imgui->slider_float(_L("Spacing from bed"), &settings.distance_from_bed, dist_bed_min, 100.0f, "%5.2f") || dist_bed_min > settings.distance_from_bed) { + settings.distance_from_bed = std::max(dist_bed_min, settings.distance_from_bed); + settings_out.distance_from_bed = settings.distance_from_bed; + appcfg->set("arrange", dist_bed_key.c_str(), float_to_string_decimal_point(settings_out.distance_from_bed)); + settings_changed = true; + } + if (imgui->checkbox(_L("Enable rotations (slow)"), settings.enable_rotation)) { settings_out.enable_rotation = settings.enable_rotation; appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0"); @@ -4566,6 +4594,7 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x) settings_out = ArrangeSettings{}; settings_out.distance = std::max(dist_min, settings_out.distance); appcfg->set("arrange", dist_key.c_str(), float_to_string_decimal_point(settings_out.distance)); + appcfg->set("arrange", dist_bed_key.c_str(), float_to_string_decimal_point(settings_out.distance_from_bed)); appcfg->set("arrange", rot_key.c_str(), settings_out.enable_rotation? "1" : "0"); settings_changed = true; } From fa897fbda4fc50441ba1ab327f0b847f46144e3f Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 12 Sep 2022 10:41:24 +0200 Subject: [PATCH 02/17] Fix: bed filling not respecting arrange bounds --- src/slic3r/GUI/Jobs/FillBedJob.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/GUI/Jobs/FillBedJob.cpp b/src/slic3r/GUI/Jobs/FillBedJob.cpp index c7d69eb50..5eefc14b6 100644 --- a/src/slic3r/GUI/Jobs/FillBedJob.cpp +++ b/src/slic3r/GUI/Jobs/FillBedJob.cpp @@ -117,6 +117,7 @@ void FillBedJob::process(Ctl &ctl) arrangement::ArrangeParams params; params.allow_rotations = settings.enable_rotation; params.min_obj_distance = scaled(settings.distance); + params.min_bed_distance = scaled(settings.distance_from_bed); bool do_stop = false; params.stopcondition = [&ctl, &do_stop]() { From 4d9530deb7df61f239d5e873fd7f0edf6dfde365 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 13 Sep 2022 15:07:40 +0200 Subject: [PATCH 03/17] Prevent potential data races in arrange job --- src/slic3r/GUI/Jobs/ArrangeJob.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index e75304d7a..cb26fae0b 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -167,12 +167,16 @@ void ArrangeJob::process(Ctl &ctl) static const auto arrangestr = _u8L("Arranging"); ctl.update_status(0, arrangestr); - ctl.call_on_main_thread([this]{ prepare(); }).wait();; - arrangement::ArrangeParams params = get_arrange_params(m_plater); + arrangement::ArrangeParams params; + Points bedpts; + ctl.call_on_main_thread([this, ¶ms, &bedpts]{ + prepare(); + params = get_arrange_params(m_plater); + bedpts = get_bed_shape(*m_plater->config()); + }).wait();; auto count = unsigned(m_selected.size() + m_unprintable.size()); - Points bedpts = get_bed_shape(*m_plater->config()); params.stopcondition = [&ctl]() { return ctl.was_canceled(); }; From 3e53abf9bd6a44a24ee5bad23e9c3de6feba0ab6 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 13 Sep 2022 16:50:18 +0200 Subject: [PATCH 04/17] Remove junk code --- src/slic3r/GUI/Jobs/ArrangeJob.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index cb26fae0b..6627b7bb7 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -1,7 +1,6 @@ #include "ArrangeJob.hpp" #include "libslic3r/BuildVolume.hpp" -#include "libslic3r/MTUtils.hpp" #include "libslic3r/Model.hpp" #include "slic3r/GUI/Plater.hpp" @@ -174,7 +173,7 @@ void ArrangeJob::process(Ctl &ctl) prepare(); params = get_arrange_params(m_plater); bedpts = get_bed_shape(*m_plater->config()); - }).wait();; + }).wait(); auto count = unsigned(m_selected.size() + m_unprintable.size()); From 6197acf5760b68834bf0ab8fa408ee99c7bfb16c Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 13 Sep 2022 16:51:20 +0200 Subject: [PATCH 05/17] Don't arrange items if the bed has negative area Also interpret a bounding box with maxCorner lower then minCorner as a negative area box --- .../include/libnest2d/geometry_traits.hpp | 5 +++-- src/libslic3r/Arrange.cpp | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/libnest2d/include/libnest2d/geometry_traits.hpp b/src/libnest2d/include/libnest2d/geometry_traits.hpp index f388e37b1..1192f4d4d 100644 --- a/src/libnest2d/include/libnest2d/geometry_traits.hpp +++ b/src/libnest2d/include/libnest2d/geometry_traits.hpp @@ -198,9 +198,10 @@ public: inline P center() const BP2D_NOEXCEPT; - template> + template> inline Unit area() const BP2D_NOEXCEPT { - return Unit(width())*height(); + Unit s = std::signbit(width()) || std::signbit(height()) ? Unit(-1) : Unit(1); + return s * libnest2d::abs(width() * height()); } static inline _Box infinite(const P ¢er = {TCoord

(0), TCoord

(0)}); diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index a313c4626..a6aecd205 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -497,11 +497,11 @@ void _arrange( mod_params.min_obj_distance = 0; AutoArranger arranger{corrected_bin, mod_params, progressfn, stopfn}; - + auto infl = coord_t(std::ceil(params.min_obj_distance / 2.0)); for (Item& itm : shapes) itm.inflate(infl); for (Item& itm : excludes) itm.inflate(infl); - + remove_large_items(excludes, corrected_bin); // If there is something on the plate @@ -511,7 +511,7 @@ void _arrange( inp.reserve(shapes.size() + excludes.size()); for (auto &itm : shapes ) inp.emplace_back(itm); for (auto &itm : excludes) inp.emplace_back(itm); - + // Use the minimum bounding box rotation as a starting point. // TODO: This only works for convex hull. If we ever switch to concave // polygon nesting, a convex hull needs to be calculated. @@ -528,7 +528,13 @@ void _arrange( } } - arranger(inp.begin(), inp.end()); + if (sl::area(corrected_bin) > 0) + arranger(inp.begin(), inp.end()); + else { + for (Item &itm : inp) + itm.binId(BIN_ID_UNSET); + } + for (Item &itm : inp) itm.inflate(-infl); } From 66bc6ecc5c7efcf2885cf2a991e7f6b4cd42e171 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 14 Sep 2022 13:21:14 +0200 Subject: [PATCH 06/17] Fix build on msvc --- src/libnest2d/include/libnest2d/geometry_traits.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libnest2d/include/libnest2d/geometry_traits.hpp b/src/libnest2d/include/libnest2d/geometry_traits.hpp index 1192f4d4d..0096ef610 100644 --- a/src/libnest2d/include/libnest2d/geometry_traits.hpp +++ b/src/libnest2d/include/libnest2d/geometry_traits.hpp @@ -200,7 +200,8 @@ public: template> inline Unit area() const BP2D_NOEXCEPT { - Unit s = std::signbit(width()) || std::signbit(height()) ? Unit(-1) : Unit(1); + constexpr TCoord

Zero{0}; + Unit s = width() < Zero || height() < Zero ? Unit(-1) : Unit(1); return s * libnest2d::abs(width() * height()); } From c1fd265d18e4ba1dcee7f2a144907db22d69277c Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 14 Sep 2022 13:43:57 +0200 Subject: [PATCH 07/17] Fix jumping hidden items larger than the bed after hitting arrange --- src/slic3r/GUI/Jobs/ArrangeJob.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index e75304d7a..180aa5d84 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -239,7 +239,9 @@ void ArrangeJob::finalize(bool canceled, std::exception_ptr &eptr) { // Move the unprintable items to the last virtual bed. for (ArrangePolygon &ap : m_unprintable) { - ap.bed_idx += beds + 1; + if (ap.bed_idx >= 0) + ap.bed_idx += beds + 1; + ap.apply(); } From 086fb28299160c702c76230b3b60c37b8dbdab9e Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Wed, 14 Sep 2022 16:39:18 +0200 Subject: [PATCH 08/17] Fix failing tests --- src/libnest2d/include/libnest2d/geometry_traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libnest2d/include/libnest2d/geometry_traits.hpp b/src/libnest2d/include/libnest2d/geometry_traits.hpp index 0096ef610..134ec73a0 100644 --- a/src/libnest2d/include/libnest2d/geometry_traits.hpp +++ b/src/libnest2d/include/libnest2d/geometry_traits.hpp @@ -202,7 +202,7 @@ public: inline Unit area() const BP2D_NOEXCEPT { constexpr TCoord

Zero{0}; Unit s = width() < Zero || height() < Zero ? Unit(-1) : Unit(1); - return s * libnest2d::abs(width() * height()); + return s * libnest2d::abs(Unit(width()) * height()); } static inline _Box infinite(const P ¢er = {TCoord

(0), TCoord

(0)}); From 429b65dba3ac85e9de105f1659eaf6552a7bafb8 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 19 Sep 2022 09:22:30 +0200 Subject: [PATCH 09/17] Small code refactoring. DiffPresetDlg: Rename save() to is_save_confirmed(). --- src/slic3r/GUI/UnsavedChangesDialog.cpp | 4 ++-- src/slic3r/GUI/UnsavedChangesDialog.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index c04a536ef..5d04c1962 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -2010,7 +2010,7 @@ void DiffPresetDialog::update_compatibility(const std::string& preset_name, Pres } } -bool DiffPresetDialog::save() +bool DiffPresetDialog::is_save_confirmed() { presets_to_save.clear(); @@ -2056,7 +2056,7 @@ std::vector DiffPresetDialog::get_options_to_save(Preset::Type type void DiffPresetDialog::button_event(Action act) { if (act == Action::Save) { - if (save()) { + if (is_save_confirmed()) { size_t saved_cnt = 0; for (const auto& preset : presets_to_save) if (wxGetApp().preset_bundle->transfer_and_save(preset.type, preset.from_name, preset.to_name, preset.new_name, get_options_to_save(preset.type))) diff --git a/src/slic3r/GUI/UnsavedChangesDialog.hpp b/src/slic3r/GUI/UnsavedChangesDialog.hpp index 1592914fc..69f808451 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.hpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.hpp @@ -379,7 +379,7 @@ class DiffPresetDialog : public DPIDialog std::vector get_options_to_save(Preset::Type type); void button_event(Action act); - bool save(); + bool is_save_confirmed(); struct DiffPresets { From 4014bcbbd57c3b734cb7eb7874b5c14e67a2aa57 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 17 Aug 2022 15:27:57 +0200 Subject: [PATCH 10/17] Fix for #8618 - Unable to "split to objects" on macOS + Fix for #SPE-1266 - Detach from system filament preset button is still visible when preset is detached --- src/slic3r/GUI/GUI_Factories.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 6a3dad5f4..8f69ca811 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -941,7 +941,7 @@ void MenuFactory::create_object_menu() []() { return plater()->can_split(false); }, m_parent); append_submenu(&m_object_menu, split_menu, wxID_ANY, _L("Split"), _L("Split the selected object"), "", - []() { return plater()->can_split(true) && wxGetApp().get_mode() > comSimple; }, m_parent); + []() { return plater()->can_split(true); }, m_parent); m_object_menu.AppendSeparator(); // "Height range Modifier" and "Add (volumes)" menu items will be added later in append_menu_items_add_volume() diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index d27bfc931..8f38a1525 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -919,7 +919,7 @@ void Tab::update_visibility() page->update_visibility(m_mode, page.get() == m_active_page); rebuild_page_tree(); - if (m_type == Preset::TYPE_SLA_PRINT || m_type == Preset::TYPE_PRINT) + if (m_type != Preset::TYPE_PRINTER) update_description_lines(); Layout(); From 21a25fa0a21756d12de799fdf4fe6574f86a2b34 Mon Sep 17 00:00:00 2001 From: rtyr <36745189+rtyr@users.noreply.github.com> Date: Tue, 20 Sep 2022 08:42:36 +0200 Subject: [PATCH 11/17] Creality 0.2.2 https://github.com/prusa3d/PrusaSlicer/pull/8848 --- resources/profiles/Creality.idx | 1 + resources/profiles/Creality.ini | 169 +++++++++++++++++++++++--------- 2 files changed, 123 insertions(+), 47 deletions(-) diff --git a/resources/profiles/Creality.idx b/resources/profiles/Creality.idx index 471ca8c56..80d951b0b 100644 --- a/resources/profiles/Creality.idx +++ b/resources/profiles/Creality.idx @@ -1,4 +1,5 @@ min_slic3r_version = 2.5.0-alpha0 +0.2.2 General improvements. 0.2.1 Added Ender 3 Neo and Ender 3 S1 Plus. Various updates. 0.2.0 Added alternative nozzle support 0.1.5 Added Ender-3 S1 Pro diff --git a/resources/profiles/Creality.ini b/resources/profiles/Creality.ini index 82c1c0bd6..4fab957e2 100644 --- a/resources/profiles/Creality.ini +++ b/resources/profiles/Creality.ini @@ -5,7 +5,7 @@ name = Creality # Configuration version of this file. Config file will only be installed, if the config_version differs. # This means, the server may force the PrusaSlicer configuration to be downgraded. -config_version = 0.2.1 +config_version = 0.2.2 # Where to get the updates from? config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/Creality/ # changelog_url = https://files.prusa3d.com/?latest=slicer-profiles&lng=%1% @@ -131,6 +131,15 @@ bed_model = ender3_bed.stl bed_texture = ender3.svg default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA Matt @CREALITY; Devil Design PLA Galaxy @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 3DJAKE ecoPLA Matt @CREALITY; 3DJAKE ecoPLA Tough @CREALITY; 123-3D Jupiter PLA @CREALITY; Verbatim PLA @CREALITY +#[printer_model:ENDER5PRO] +#name = Creality Ender-5 Pro +#variants = 0.4; 0.3; 0.5; 0.6 +#technology = FFF +#family = ENDER +#bed_model = ender3_bed.stl +#bed_texture = ender3.svg +#default_materials = Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Creality PLA @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY; AzureFilm PLA @CREALITY; Devil Design PLA @CREALITY; Devil Design PLA Matt @CREALITY; Devil Design PLA Galaxy @CREALITY; Extrudr PLA NX2 @CREALITY; Real Filament PLA @CREALITY; Velleman PLA @CREALITY; 3DJAKE ecoPLA @CREALITY; 3DJAKE ecoPLA Matt @CREALITY; 3DJAKE ecoPLA Tough @CREALITY; 123-3D Jupiter PLA @CREALITY; Verbatim PLA @CREALITY + [printer_model:ENDER5PLUS] name = Creality Ender-5 Plus variants = 0.4; 0.3; 0.5; 0.6 @@ -1085,10 +1094,21 @@ bed_temperature = 60 first_layer_temperature = 205 first_layer_bed_temperature = 60 filament_cost = 26.99 -filament_density = 1.36 +filament_density = 1.37 filament_colour = #FF4640 filament_spool_weight = 180 +[filament:VOXELPLA PLA Plus @CREALITY] +inherits = *PLA* +filament_vendor = VOXELPLA +temperature = 200 +bed_temperature = 60 +first_layer_temperature = 200 +first_layer_bed_temperature = 60 +filament_cost = 16.99 +filament_density = 1.24 +filament_colour = #2862C4 + # Common printer preset @@ -1106,6 +1126,7 @@ remaining_times = 0 machine_max_acceleration_e = 5000 machine_max_acceleration_extruding = 500 machine_max_acceleration_retracting = 1000 +machine_max_acceleration_travel = 500 machine_max_acceleration_x = 500 machine_max_acceleration_y = 500 machine_max_acceleration_z = 100 @@ -1119,6 +1140,7 @@ machine_max_jerk_y = 8 machine_max_jerk_z = 0.4 machine_min_extruding_rate = 0 machine_min_travel_rate = 0 +machine_limits_usage = emit_to_gcode layer_gcode = ;AFTER_LAYER_CHANGE\n;{layer_z} max_print_height = 250 printer_notes = @@ -1144,7 +1166,11 @@ z_offset = 0 printer_model = default_filament_profile = "Generic PLA @CREALITY" start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM140 S{first_layer_bed_temperature[0]} ; set final bed temp\nM104 S150 ; set temporary nozzle temp to prevent oozing during homing\nG4 S10 ; allow partial nozzle warmup\nG28 ; home all axis\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S{first_layer_temperature[0]} ; set final nozzle temp\nM190 S{first_layer_bed_temperature[0]} ; wait for bed temp to stabilize\nM109 S{first_layer_temperature[0]} ; wait for nozzle temp to stabilize\nG1 Z0.28 F240\nG92 E0\nG1 Y140 E10 F1500 ; prime the nozzle\nG1 X2.3 F5000\nG92 E0\nG1 Y10 E10 F1200 ; prime the nozzle\nG92 E0 -end_gcode = {if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600 ; Move print head up{endif}\nG1 X5 Y{print_bed_max[1]*0.8} F{travel_speed*60} ; present print\n{if max_layer_z < max_print_height-10}G1 Z{z_offset+min(max_layer_z+70, max_print_height-10)} F600 ; Move print head further up{endif}\n{if max_layer_z < max_print_height*0.6}G1 Z{max_print_height*0.6} F600 ; Move print head further up{endif}\nM140 S0 ; turn off heatbed\nM104 S0 ; turn off temperature\nM107 ; turn off fan\nM84 X Y E ; disable motors +end_gcode = {if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600 ; Move print head up{endif}\nG1 X5 Y{print_bed_max[1]*0.85} F{travel_speed*60} ; present print\n{if max_layer_z < max_print_height-10}G1 Z{z_offset+min(max_layer_z+70, max_print_height-10)} F600 ; Move print head further up{endif}\n{if max_layer_z < max_print_height*0.6}G1 Z{max_print_height*0.6} F600 ; Move print head further up{endif}\nM140 S0 ; turn off heatbed\nM104 S0 ; turn off temperature\nM107 ; turn off fan\nM84 X Y E ; disable motors + +# Intended for printers that have exclusively shipped with a 32bit mainboard +[printer:*32bitmainboard*] +gcode_flavor = marlin2 # Intended for printers equipped with a strain gauge mechanism, like the CR-6 series [printer:*straingauge*] @@ -1158,6 +1184,10 @@ start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM140 [printer:*slowabl*] start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM140 S{first_layer_bed_temperature[0]} ; set final bed temp\nM104 S150 ; set temporary nozzle temp to prevent oozing during homing and auto bed leveling\nM190 S{first_layer_bed_temperature[0]} ; wait for bed temp to stabilize\nG28 ; home all axis\nG29 ; auto bed levelling\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S{first_layer_temperature[0]} ; set final nozzle temp\nM109 S{first_layer_temperature[0]} ; wait for nozzle temp to stabilize\nG1 Z0.28 F240\nG92 E0\nG1 Y140 E10 F1500 ; prime the nozzle\nG1 X2.3 F5000\nG92 E0\nG1 Y10 E10 F1200 ; prime the nozzle\nG92 E0 +# intended for printers that have RESTORE_LEVELING_AFTER_G28 enabled in firmware +[printer:*storedabl*] +start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM140 S{first_layer_bed_temperature[0]} ; set final bed temp\nM104 S150 ; set temporary nozzle temp to prevent oozing during homing\nG4 S10 ; allow partial nozzle warmup\nG28 ; home all axis and restore leveling\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S{first_layer_temperature[0]} ; set final nozzle temp\nM190 S{first_layer_bed_temperature[0]} ; wait for bed temp to stabilize\nM109 S{first_layer_temperature[0]} ; wait for nozzle temp to stabilize\nG1 Z0.28 F240\nG92 E0\nG1 Y140 E10 F1500 ; prime the nozzle\nG1 X2.3 F5000\nG92 E0\nG1 Y10 E10 F1200 ; prime the nozzle\nG92 E0 + # Intended for printers with vendor official firmware verified to support M25 [printer:*pauseprint*] pause_print_gcode = M25 ; pause print @@ -1166,16 +1196,31 @@ pause_print_gcode = M25 ; pause print [printer:*descendingz*] end_gcode = {if max_layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+2, max_print_height)} F600{endif} ; Move print bed down\nG1 X50 Y50 F{travel_speed*60} ; move print head out of the way\n{if max_layer_z < max_print_height-10}G1 Z{z_offset+max_print_height-10} F600{endif} ; Move print bed close to the bottom\nM140 S0 ; turn off heatbed\nM104 S0 ; turn off temperature\nM107 ; turn off fan\nM84 X Y E ; disable motors +# Intended for printers with a much larger bed, like the CR-10 S4/S5 series +[printer:*largebedinertia*] +machine_max_acceleration_x = 300 +machine_max_acceleration_y = 300 +machine_max_feedrate_x = 300 +machine_max_feedrate_y = 300 + [printer:*bowdencapricorn*] +#max_volumetric_extrusion_rate_slope_negative = 7 +retract_length = 4 + +[printer:*bowdenshort*] +#max_volumetric_extrusion_rate_slope_negative = 7 retract_length = 4 [printer:*bowden*] +#max_volumetric_extrusion_rate_slope_negative = 6 retract_length = 5 [printer:*bowdenlong*] +#max_volumetric_extrusion_rate_slope_negative = 5 retract_length = 6 [printer:*bowdenallmetalhotend*] +#max_volumetric_extrusion_rate_slope_negative = 6 retract_length = 3 [printer:*directdriveextruder*] @@ -1247,8 +1292,11 @@ inherits = *ENDER3*; *0.6nozzle* [printer:*ENDER3BLTOUCH*] -inherits = *ENDER3*; *fastabl* +inherits = *common*; *bowden*; *fastabl* +bed_shape = 3x3,228x3,228x228,3x228 +max_print_height = 250 printer_model = ENDER3BLTOUCH +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER3BLTOUCH\nPRINTER_HAS_BOWDEN [printer:Creality Ender-3 BLTouch (0.3 mm nozzle)] inherits = *ENDER3BLTOUCH*; *0.3nozzle* @@ -1267,7 +1315,9 @@ inherits = *ENDER3BLTOUCH*; *0.6nozzle* [printer:*ENDER3PRO*] -inherits = *ENDER3*; *pauseprint* +inherits = *common*; *bowden*; *pauseprint* +bed_shape = 3x3,228x3,228x228,3x228 +max_print_height = 250 printer_model = ENDER3PRO printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER3PRO\nPRINTER_HAS_BOWDEN @@ -1276,7 +1326,7 @@ inherits = *ENDER3PRO*; *0.3nozzle* [printer:Creality Ender-3 Pro (0.4 mm nozzle)] inherits = *ENDER3PRO*; *0.4nozzle* -renamed_From = "Creality Ender-3 Pro" +renamed_from = "Creality Ender-3 Pro" [printer:Creality Ender-3 Pro (0.5 mm nozzle)] inherits = *ENDER3PRO*; *0.5nozzle* @@ -1287,7 +1337,9 @@ inherits = *ENDER3PRO*; *0.6nozzle* [printer:*ENDER3NEO*] -inherits = *ENDER3*; *fastabl* +inherits = *common*; *bowden*; *fastabl*; *32bitmainboard* +bed_shape = 3x3,228x3,228x228,3x228 +max_print_height = 250 printer_model = ENDER3NEO printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER3NEO\nPRINTER_HAS_BOWDEN @@ -1317,7 +1369,7 @@ inherits = *ENDER3V2*; *0.3nozzle* [printer:Creality Ender-3 V2 (0.4 mm nozzle)] inherits = *ENDER3V2*; *0.4nozzle* -renamed_From = "Creality Ender-3 V2"; "Creality Ender-3V2" +renamed_from = "Creality Ender-3 V2"; "Creality Ender-3V2" [printer:Creality Ender-3 V2 (0.5 mm nozzle)] inherits = *ENDER3V2*; *0.5nozzle* @@ -1328,7 +1380,7 @@ inherits = *ENDER3V2*; *0.6nozzle* [printer:*ENDER3V2NEO*] -inherits = *common*; *bowden*; *fastabl* +inherits = *common*; *bowden*; *fastabl*; *32bitmainboard* bed_shape = 5x0,215x0,215x220,5x220 max_print_height = 250 printer_model = ENDER3V2NEO @@ -1349,7 +1401,7 @@ inherits = *ENDER3V2NEO*; *0.6nozzle* [printer:*ENDER3S1*] -inherits = *common*; *fastabl*; *spriteextruder*; *pauseprint* +inherits = *common*; *storedabl*; *spriteextruder*; *pauseprint* bed_shape = 5x0,215x0,215x220,5x220 max_print_height = 270 printer_model = ENDER3S1 @@ -1360,7 +1412,7 @@ inherits = *ENDER3S1*; *0.3nozzle* [printer:Creality Ender-3 S1 (0.4 mm nozzle)] inherits = *ENDER3S1*; *0.4nozzle* -renamed_From = "Creality Ender-3 S1" +renamed_from = "Creality Ender-3 S1" [printer:Creality Ender-3 S1 (0.5 mm nozzle)] inherits = *ENDER3S1*; *0.5nozzle* @@ -1371,7 +1423,7 @@ inherits = *ENDER3S1*; *0.6nozzle* [printer:*ENDER3S1PRO*] -inherits = *common*; *fastabl*; *spriteextruder*; *pauseprint* +inherits = *common*; *storedabl*; *spriteextruder*; *pauseprint* bed_shape = 5x0,215x0,215x220,5x220 max_print_height = 270 printer_model = ENDER3S1PRO @@ -1382,7 +1434,7 @@ inherits = *ENDER3S1PRO*; *0.3nozzle* [printer:Creality Ender-3 S1 Pro (0.4 mm nozzle)] inherits = *ENDER3S1PRO*; *0.4nozzle* -renamed_From = "Creality Ender-3 S1 Pro" +renamed_from = "Creality Ender-3 S1 Pro" [printer:Creality Ender-3 S1 Pro (0.5 mm nozzle)] inherits = *ENDER3S1PRO*; *0.5nozzle* @@ -1393,7 +1445,7 @@ inherits = *ENDER3S1PRO*; *0.6nozzle* [printer:*ENDER3S1PLUS*] -inherits = *common*; *slowabl*; *spriteextruder*; *pauseprint* +inherits = *common*; *storedabl*; *spriteextruder*; *pauseprint* bed_shape = 5x5,295x5,295x295,5x295 max_print_height = 300 printer_model = ENDER3S1PLUS @@ -1425,7 +1477,7 @@ inherits = *ENDER3MAX*; *0.3nozzle* [printer:Creality Ender-3 Max (0.4 mm nozzle)] inherits = *ENDER3MAX*; *0.4nozzle* -renamed_From = "Creality Ender-3 Max" +renamed_from = "Creality Ender-3 Max" [printer:Creality Ender-3 Max (0.5 mm nozzle)] inherits = *ENDER3MAX*; *0.5nozzle* @@ -1436,7 +1488,7 @@ inherits = *ENDER3MAX*; *0.6nozzle* [printer:*ENDER3MAXNEO*] -inherits = *common*; *bowdenlong*; *slowabl* +inherits = *common*; *bowdenlong*; *slowabl*; *32bitmainboard* bed_shape = 5x5,295x5,295x295,5x295 max_print_height = 320 printer_model = ENDER3MAXNEO @@ -1468,7 +1520,7 @@ inherits = *ENDER4*; *0.3nozzle* [printer:Creality Ender-4 (0.4 mm nozzle)] inherits = *ENDER4*; *0.4nozzle* -renamed_From = "Creality Ender-4" +renamed_from = "Creality Ender-4" [printer:Creality Ender-4 (0.5 mm nozzle)] inherits = *ENDER4*; *0.5nozzle* @@ -1492,7 +1544,7 @@ inherits = *ENDER5*; *0.3nozzle* [printer:Creality Ender-5 (0.4 mm nozzle)] inherits = *ENDER5*; *0.4nozzle* -renamed_From = "Creality Ender-5" +renamed_from = "Creality Ender-5" [printer:Creality Ender-5 (0.5 mm nozzle)] inherits = *ENDER5*; *0.5nozzle* @@ -1502,6 +1554,29 @@ inherits = *ENDER5*; *0.6nozzle* +#[printer:*ENDER5PRO*] +#inherits = *common*; *bowdencapricorn*; *descendingz* +#bed_shape = 5x2.5,225x2.5,225x222.5,5x222.5 +#max_print_height = 300 +#printer_model = ENDER5PRO +#printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER5PRO\nPRINTER_HAS_BOWDEN +#machine_max_acceleration_e = 1000 +#machine_max_feedrate_z = 5 +# +#[printer:Creality Ender-5 Pro (0.3 mm nozzle)] +#inherits = *ENDER5PRO*; *0.3nozzle* +# +#[printer:Creality Ender-5 Pro (0.4 mm nozzle)] +#inherits = *ENDER5PRO*; *0.4nozzle* +# +#[printer:Creality Ender-5 Pro (0.5 mm nozzle)] +#inherits = *ENDER5PRO*; *0.5nozzle* +# +#[printer:Creality Ender-5 Pro (0.6 mm nozzle)] +#inherits = *ENDER5PRO*; *0.6nozzle* + + + [printer:*ENDER5PLUS*] inherits = *common*; *bowdenlong*; *slowabl*; *descendingz* bed_shape = 5x5,355x5,355x355,5x355 @@ -1518,7 +1593,7 @@ inherits = *ENDER5PLUS*; *0.3nozzle* [printer:Creality Ender-5 Plus (0.4 mm nozzle)] inherits = *ENDER5PLUS*; *0.4nozzle* -renamed_From = "Creality Ender-5 Plus" +renamed_from = "Creality Ender-5 Plus" [printer:Creality Ender-5 Plus (0.5 mm nozzle)] inherits = *ENDER5PLUS*; *0.5nozzle* @@ -1540,7 +1615,7 @@ inherits = *ENDER6*; *0.3nozzle* [printer:Creality Ender-6 (0.4 mm nozzle)] inherits = *ENDER6*; *0.4nozzle* -renamed_From = "Creality Ender-6" +renamed_from = "Creality Ender-6" [printer:Creality Ender-6 (0.5 mm nozzle)] inherits = *ENDER6*; *0.5nozzle* @@ -1562,7 +1637,7 @@ inherits = *ENDER7*; *0.3nozzle* [printer:Creality Ender-7 (0.4 mm nozzle)] inherits = *ENDER7*; *0.4nozzle* -renamed_From = "Creality Ender-7" +renamed_from = "Creality Ender-7" [printer:Creality Ender-7 (0.5 mm nozzle)] inherits = *ENDER7*; *0.5nozzle* @@ -1573,7 +1648,7 @@ inherits = *ENDER7*; *0.6nozzle* [printer:*ENDER2*] -inherits = *common*; *bowden* +inherits = *common*; *bowdenshort* bed_shape = 0x0,150x0,150x150,0x150 max_print_height = 200 printer_model = ENDER2 @@ -1584,7 +1659,7 @@ inherits = *ENDER2*; *0.3nozzle* [printer:Creality Ender-2 (0.4 mm nozzle)] inherits = *ENDER2*; *0.4nozzle* -renamed_From = "Creality Ender-2"; "Creality ENDER-2" +renamed_from = "Creality Ender-2"; "Creality ENDER-2" [printer:Creality Ender-2 (0.5 mm nozzle)] inherits = *ENDER2*; *0.5nozzle* @@ -1595,7 +1670,7 @@ inherits = *ENDER2*; *0.6nozzle* [printer:*ENDER2PRO*] -inherits = *common*; *bowden* +inherits = *common*; *bowdenshort* bed_shape = 2.5x2.5,160x2.5,160x160,2.5x160 max_print_height = 180 printer_model = ENDER2PRO @@ -1606,7 +1681,7 @@ inherits = *ENDER2PRO*; *0.3nozzle* [printer:Creality Ender-2 Pro (0.4 mm nozzle)] inherits = *ENDER2PRO*; *0.4nozzle* -renamed_From = "Creality Ender-2 Pro"; "Creality ENDER-2 Pro" +renamed_from = "Creality Ender-2 Pro"; "Creality ENDER-2 Pro" [printer:Creality Ender-2 Pro (0.5 mm nozzle)] inherits = *ENDER2PRO*; *0.5nozzle* @@ -1628,7 +1703,7 @@ inherits = *CR5PRO*; *0.3nozzle* [printer:Creality CR-5 Pro (0.4 mm nozzle)] inherits = *CR5PRO*; *0.4nozzle* -renamed_From = "Creality CR-5 Pro" +renamed_from = "Creality CR-5 Pro" [printer:Creality CR-5 Pro (0.5 mm nozzle)] inherits = *CR5PRO*; *0.5nozzle* @@ -1650,7 +1725,7 @@ inherits = *CR5PROH*; *0.3nozzle* [printer:Creality CR-5 Pro H (0.4 mm nozzle)] inherits = *CR5PROH*; *0.4nozzle* -renamed_From = "Creality CR-5 Pro H" +renamed_from = "Creality CR-5 Pro H" [printer:Creality CR-5 Pro H (0.5 mm nozzle)] inherits = *CR5PROH*; *0.5nozzle* @@ -1671,7 +1746,7 @@ inherits = *CR6SE*; *0.3nozzle* [printer:Creality CR-6 SE (0.4 mm nozzle)] inherits = *CR6SE*; *0.4nozzle* -renamed_From = "Creality CR-6 SE" +renamed_from = "Creality CR-6 SE" [printer:Creality CR-6 SE (0.5 mm nozzle)] inherits = *CR6SE*; *0.5nozzle* @@ -1693,7 +1768,7 @@ inherits = *CR6MAX*; *0.3nozzle* [printer:Creality CR-6 Max (0.4 mm nozzle)] inherits = *CR6MAX*; *0.4nozzle* -renamed_From = "Creality CR-6 Max" +renamed_from = "Creality CR-6 Max" [printer:Creality CR-6 Max (0.5 mm nozzle)] inherits = *CR6MAX*; *0.5nozzle* @@ -1715,7 +1790,7 @@ inherits = *CR10SMART*; *0.3nozzle* [printer:Creality CR-10 SMART (0.4 mm nozzle)] inherits = *CR10SMART*; *0.4nozzle* -renamed_From = "Creality CR-10 SMART" +renamed_from = "Creality CR-10 SMART" [printer:Creality CR-10 SMART (0.5 mm nozzle)] inherits = *CR10SMART*; *0.5nozzle* @@ -1758,7 +1833,7 @@ inherits = *CR10MINI*; *0.3nozzle* [printer:Creality CR-10 Mini (0.4 mm nozzle)] inherits = *CR10MINI*; *0.4nozzle* -renamed_From = "Creality CR-10 Mini" +renamed_from = "Creality CR-10 Mini" [printer:Creality CR-10 Mini (0.5 mm nozzle)] inherits = *CR10MINI*; *0.5nozzle* @@ -1780,7 +1855,7 @@ inherits = *CR10MAX*; *0.3nozzle* [printer:Creality CR-10 Max (0.4 mm nozzle)] inherits = *CR10MAX*; *0.4nozzle* -renamed_From = "Creality CR-10 Max" +renamed_from = "Creality CR-10 Max" [printer:Creality CR-10 Max (0.5 mm nozzle)] inherits = *CR10MAX*; *0.5nozzle* @@ -1802,7 +1877,7 @@ inherits = *CR10*; *0.3nozzle* [printer:Creality CR-10 (0.4 mm nozzle)] inherits = *CR10*; *0.4nozzle* -renamed_From = "Creality CR-10" +renamed_from = "Creality CR-10" [printer:Creality CR-10 (0.5 mm nozzle)] inherits = *CR10*; *0.5nozzle* @@ -1824,7 +1899,7 @@ inherits = *CR10V2*; *0.3nozzle* [printer:Creality CR-10 V2 (0.4 mm nozzle)] inherits = *CR10V2*; *0.4nozzle* -renamed_From = "Creality CR-10 V2" +renamed_from = "Creality CR-10 V2" [printer:Creality CR-10 V2 (0.5 mm nozzle)] inherits = *CR10V2*; *0.5nozzle* @@ -1846,7 +1921,7 @@ inherits = *CR10V3*; *0.3nozzle* [printer:Creality CR-10 V3 (0.4 mm nozzle)] inherits = *CR10V3*; *0.4nozzle* -renamed_From = "Creality CR-10 V3" +renamed_from = "Creality CR-10 V3" [printer:Creality CR-10 V3 (0.5 mm nozzle)] inherits = *CR10V3*; *0.5nozzle* @@ -1868,7 +1943,7 @@ inherits = *CR10S*; *0.3nozzle* [printer:Creality CR-10 S (0.4 mm nozzle)] inherits = *CR10S*; *0.4nozzle* -renamed_From = "Creality CR-10 S" +renamed_from = "Creality CR-10 S" [printer:Creality CR-10 S (0.5 mm nozzle)] inherits = *CR10S*; *0.5nozzle* @@ -1890,7 +1965,7 @@ inherits = *CR10SPRO*; *0.3nozzle* [printer:Creality CR-10 S Pro (0.4 mm nozzle)] inherits = *CR10SPRO*; *0.4nozzle* -renamed_From = "Creality CR-10 S Pro" +renamed_from = "Creality CR-10 S Pro" [printer:Creality CR-10 S Pro (0.5 mm nozzle)] inherits = *CR10SPRO*; *0.5nozzle* @@ -1912,7 +1987,7 @@ inherits = *CR10SPROV2*; *0.3nozzle* [printer:Creality CR-10 S Pro V2 (0.4 mm nozzle)] inherits = *CR10SPROV2*; *0.4nozzle* -renamed_From = "Creality CR-10 S Pro V2" +renamed_from = "Creality CR-10 S Pro V2" [printer:Creality CR-10 S Pro V2 (0.5 mm nozzle)] inherits = *CR10SPROV2*; *0.5nozzle* @@ -1923,7 +1998,7 @@ inherits = *CR10SPROV2*; *0.6nozzle* [printer:*CR10S4*] -inherits = *common*; *bowdenlong* +inherits = *common*; *bowdenlong*; *largebedinertia* bed_shape = 5x5,395x5,395x395,5x395 max_print_height = 400 printer_model = CR10S4 @@ -1934,7 +2009,7 @@ inherits = *CR10S4*; *0.3nozzle* [printer:Creality CR-10 S4 (0.4 mm nozzle)] inherits = *CR10S4*; *0.4nozzle* -renamed_From = "Creality CR-10 S4" +renamed_from = "Creality CR-10 S4" [printer:Creality CR-10 S4 (0.5 mm nozzle)] inherits = *CR10S4*; *0.5nozzle* @@ -1945,7 +2020,7 @@ inherits = *CR10S4*; *0.6nozzle* [printer:*CR10S5*] -inherits = *common*; *bowdenlong* +inherits = *common*; *bowdenlong*; *largebedinertia* bed_shape = 5x5,505x5,505x505,5x505 max_print_height = 500 printer_model = CR10S5 @@ -1956,7 +2031,7 @@ inherits = *CR10S5*; *0.3nozzle* [printer:Creality CR-10 S5 (0.4 mm nozzle)] inherits = *CR10S5*; *0.4nozzle* -renamed_From = "Creality CR-10 S5" +renamed_from = "Creality CR-10 S5" [printer:Creality CR-10 S5 (0.5 mm nozzle)] inherits = *CR10S5*; *0.5nozzle* @@ -1976,7 +2051,7 @@ inherits = *CR20*; *0.3nozzle* [printer:Creality CR-20 (0.4 mm nozzle)] inherits = *CR20*; *0.4nozzle* -renamed_From = "Creality CR-20" +renamed_from = "Creality CR-20" [printer:Creality CR-20 (0.5 mm nozzle)] inherits = *CR20*; *0.5nozzle* @@ -1996,7 +2071,7 @@ inherits = *CR20PRO*; *0.3nozzle* [printer:Creality CR-20 Pro (0.4 mm nozzle)] inherits = *CR20PRO*; *0.4nozzle* -renamed_From = "Creality CR-20 Pro" +renamed_from = "Creality CR-20 Pro" [printer:Creality CR-20 Pro (0.5 mm nozzle)] inherits = *CR20PRO*; *0.5nozzle* @@ -2018,7 +2093,7 @@ inherits = *CR200B*; *0.3nozzle* [printer:Creality CR-200B (0.4 mm nozzle)] inherits = *CR200B*; *0.4nozzle* -renamed_From = "Creality CR-200B" +renamed_from = "Creality CR-200B" [printer:Creality CR-200B (0.5 mm nozzle)] inherits = *CR200B*; *0.5nozzle* @@ -2040,7 +2115,7 @@ inherits = *CR8*; *0.3nozzle* [printer:Creality CR-8 (0.4 mm nozzle)] inherits = *CR8*; *0.4nozzle* -renamed_From = "Creality CR-8" +renamed_from = "Creality CR-8" [printer:Creality CR-8 (0.5 mm nozzle)] inherits = *CR8*; *0.5nozzle* @@ -2062,7 +2137,7 @@ inherits = *SERMOOND1*; *0.3nozzle* [printer:Creality Sermoon-D1 (0.4 mm nozzle)] inherits = *SERMOOND1*; *0.4nozzle* -renamed_From = "Creality Sermoon-D1" +renamed_from = "Creality Sermoon-D1" [printer:Creality Sermoon-D1 (0.5 mm nozzle)] inherits = *SERMOOND1*; *0.5nozzle* From 875fb6892f36a03706f4de0ad23e059ba9b42dcb Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Tue, 20 Sep 2022 10:53:42 +0200 Subject: [PATCH 12/17] Fix partial arrange behavior --- .../include/libnest2d/placers/nfpplacer.hpp | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp index 00f6a999f..5b5311d90 100644 --- a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp +++ b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp @@ -509,28 +509,24 @@ public: return diff; } - template> - PackResult trypack(Item& item, - const Range& remaining = Range()) { - auto result = _trypack(item, remaining); - - // Experimental - // if(!result) repack(item, result); - - return result; - } - ~_NofitPolyPlacer() { clearItems(); } inline void clearItems() { finalAlign(bin_); + merged_pile_ = {}; Base::clearItems(); } void preload(const ItemGroup& packeditems) { Base::preload(packeditems); + + for (const Item& itm : packeditems) + merged_pile_.emplace_back(itm.transformedShape()); + + nfp::merge(merged_pile_); + if (config_.on_preload) config_.on_preload(packeditems, config_); } @@ -606,8 +602,9 @@ private: using Edges = EdgeCache; +public: template> - PackResult _trypack( + PackResult trypack( Item& item, const Range& remaining = Range()) { @@ -897,6 +894,7 @@ private: return ret; } +private: inline void finalAlign(const RawShape& pbin) { auto bbin = sl::boundingBox(pbin); finalAlign(bbin); From 9ef826cb5f61f1865aeef8ef44812cf0d4bbdfc6 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Thu, 8 Sep 2022 11:50:58 +0200 Subject: [PATCH 13/17] Fix potential crashes in SLA normal calculation routine --- src/libslic3r/MeshNormals.cpp | 8 +++++--- src/libslic3r/SLA/SupportTreeUtils.hpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/MeshNormals.cpp b/src/libslic3r/MeshNormals.cpp index b77ab8ba2..3f7117899 100644 --- a/src/libslic3r/MeshNormals.cpp +++ b/src/libslic3r/MeshNormals.cpp @@ -24,6 +24,7 @@ Vec3d get_normal(const AABBMesh &mesh, Vec3d p; mesh.squared_distance(picking_point, faceid, p); + assert(int(faceid) < int(mesh.get_triangle_mesh()->indices.size())); auto trindex = mesh.indices(faceid); @@ -89,9 +90,10 @@ Vec3d get_normal(const AABBMesh &mesh, } } else if (edge_idx >= 0) { // the point is on and edge size_t neighbor_face = mesh.face_neighbor_index()[faceid](edge_idx); - - neigh.emplace_back(mesh.normal_by_face_id(faceid)); - neigh.emplace_back(mesh.normal_by_face_id(neighbor_face)); + if (neighbor_face < mesh.indices().size()) { + neigh.emplace_back(mesh.normal_by_face_id(faceid)); + neigh.emplace_back(mesh.normal_by_face_id(neighbor_face)); + } } if (!neigh.empty()) { // there were neighbors to count with diff --git a/src/libslic3r/SLA/SupportTreeUtils.hpp b/src/libslic3r/SLA/SupportTreeUtils.hpp index d5707dc5c..38515f879 100644 --- a/src/libslic3r/SLA/SupportTreeUtils.hpp +++ b/src/libslic3r/SLA/SupportTreeUtils.hpp @@ -517,6 +517,7 @@ bool optimize_pinhead_placement(Ex policy, Head &head) { Vec3d n = get_normal(m.emesh, head.pos); + assert(std::abs(n.norm() - 1.0) < EPSILON); // for all normals the spherical coordinates are generated and // the polar angle is saturated to 45 degrees from the bottom then From ad1c029935ecc322a3ab21b07490abda1d5318be Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 21 Sep 2022 12:53:28 +0200 Subject: [PATCH 14/17] Refactoring into DiffPresetDialog::is_save_confirmed() to fix build using VisualStudio 2022 --- src/slic3r/GUI/UnsavedChangesDialog.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 5d04c1962..73d4b767a 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -2016,12 +2016,15 @@ bool DiffPresetDialog::is_save_confirmed() std::vector types_for_save; - for (const Preset::Type& type : m_pr_technology == ptFFF ? std::initializer_list{Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT} : - std::initializer_list{Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL }) + const auto list = m_pr_technology == ptFFF ? std::initializer_list{Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT} : + std::initializer_list{ Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL }; + + for (const Preset::Type& type : list) { if (!m_tree->options(type, true).empty()) { types_for_save.emplace_back(type); presets_to_save.emplace_back(PresetToSave{ type, get_left_preset_name(type), get_right_preset_name(type), get_right_preset_name(type) }); } + } if (!types_for_save.empty()) { SavePresetDialog save_dlg(this, types_for_save, _u8L("Modified"), m_preset_bundle_right.get()); From abca0126ecbd5610d9393e6a07ecd0c8208c41ff Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 21 Sep 2022 13:59:15 +0200 Subject: [PATCH 15/17] SPE-1313 - Fixed wrong warning message when object out of bounds (SLA printers) --- src/slic3r/GUI/GLCanvas3D.cpp | 45 ++++++++++++++++++++++++++++------- src/slic3r/GUI/GLCanvas3D.hpp | 2 +- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index d07d14641..84a892859 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2406,10 +2406,25 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re const bool partlyOut = (state == ModelInstanceEPrintVolumeState::ModelInstancePVS_Partly_Outside); const bool fullyOut = (state == ModelInstanceEPrintVolumeState::ModelInstancePVS_Fully_Outside); - _set_warning_notification(EWarning::ObjectClashed, partlyOut); - _set_warning_notification(EWarning::ObjectOutside, fullyOut); - if (printer_technology != ptSLA || !contained_min_one) + if (printer_technology != ptSLA) { + _set_warning_notification(EWarning::ObjectClashed, partlyOut); + _set_warning_notification(EWarning::ObjectOutside, fullyOut); _set_warning_notification(EWarning::SlaSupportsOutside, false); + } + else { + const auto [res, volume] = _is_any_volume_outside(); + const bool is_support = volume != nullptr && volume->is_sla_support(); + if (is_support) { + _set_warning_notification(EWarning::ObjectClashed, false); + _set_warning_notification(EWarning::ObjectOutside, false); + _set_warning_notification(EWarning::SlaSupportsOutside, partlyOut || fullyOut); + } + else { + _set_warning_notification(EWarning::ObjectClashed, partlyOut); + _set_warning_notification(EWarning::ObjectOutside, fullyOut); + _set_warning_notification(EWarning::SlaSupportsOutside, false); + } + } post_event(Event(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, contained_min_one && !m_model->objects.empty() && !partlyOut)); @@ -2516,6 +2531,7 @@ void GLCanvas3D::load_sla_preview() reset_volumes(); _load_sla_shells(); _update_sla_shells_outside_state(); + _set_warning_notification_if_needed(EWarning::ObjectClashed); _set_warning_notification_if_needed(EWarning::SlaSupportsOutside); } } @@ -5855,7 +5871,7 @@ void GLCanvas3D::_render_background() (current_printer_technology() != ptSLA || !m_volumes.empty()); if (!m_volumes.empty()) - use_error_color &= _is_any_volume_outside(); + use_error_color &= _is_any_volume_outside().first; else use_error_color &= m_gcode_viewer.has_data() && !m_gcode_viewer.is_contained_in_bed(); } @@ -7650,8 +7666,19 @@ void GLCanvas3D::_set_warning_notification_if_needed(EWarning warning) { _set_current(); bool show = false; - if (!m_volumes.empty()) - show = _is_any_volume_outside(); + if (!m_volumes.empty()) { + if (current_printer_technology() == ptSLA) { + const auto [res, volume] = _is_any_volume_outside(); + if (res) { + if (warning == EWarning::ObjectClashed) + show = !volume->is_sla_support(); + else if (warning == EWarning::SlaSupportsOutside) + show = volume->is_sla_support(); + } + } + else + show = _is_any_volume_outside().first; + } else { if (wxGetApp().is_editor()) { if (current_printer_technology() != ptSLA) @@ -7708,14 +7735,14 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state) } } -bool GLCanvas3D::_is_any_volume_outside() const +std::pair GLCanvas3D::_is_any_volume_outside() const { for (const GLVolume* volume : m_volumes.volumes) { if (volume != nullptr && volume->is_outside) - return true; + return std::make_pair(true, volume); } - return false; + return std::make_pair(false, nullptr); } void GLCanvas3D::_update_selection_from_hover() diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 4b78b66d9..ec6f82011 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -1075,7 +1075,7 @@ private: // generates a warning notification containing the given message void _set_warning_notification(EWarning warning, bool state); - bool _is_any_volume_outside() const; + std::pair _is_any_volume_outside() const; // updates the selection from the content of m_hover_volume_idxs void _update_selection_from_hover(); From bb993b8f94de3cf07af2b98d610be0d1b8f6b29a Mon Sep 17 00:00:00 2001 From: PavelMikus Date: Fri, 23 Sep 2022 09:59:26 +0200 Subject: [PATCH 16/17] Greatly reduce curling of Rear seams, revert previous ineffective change SPE-1310 --- src/libslic3r/GCode/SeamPlacer.cpp | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index 0f4e43a07..926538ec9 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -1,7 +1,7 @@ #include "SeamPlacer.hpp" -#include "Point.hpp" -#include "libslic3r.h" +#include "Color.hpp" +#include "PrintConfig.hpp" #include "tbb/parallel_for.h" #include "tbb/blocked_range.h" #include "tbb/parallel_reduce.h" @@ -731,9 +731,8 @@ void gather_enforcers_blockers(GlobalModelInfo &result, const PrintObject *po) { struct SeamComparator { SeamPosition setup; float angle_importance; - Vec2f rear_attractor; - explicit SeamComparator(SeamPosition setup, const Vec2f& rear_attractor = Vec2f::Zero()) : - setup(setup), rear_attractor(rear_attractor) { + explicit SeamComparator(SeamPosition setup) : + setup(setup) { angle_importance = setup == spNearest ? SeamPlacer::angle_importance_nearest : SeamPlacer::angle_importance_aligned; } @@ -764,9 +763,8 @@ struct SeamComparator { return false; } - if (setup == SeamPosition::spRear) { - return (a.position.head<2>() - rear_attractor).squaredNorm() < - (b.position.head<2>() - rear_attractor).squaredNorm(); + if (setup == SeamPosition::spRear && a.position.y() != b.position.y()) { + return a.position.y() > b.position.y(); } float distance_penalty_a = 0.0f; @@ -828,8 +826,7 @@ struct SeamComparator { } if (setup == SeamPosition::spRear) { - return (a.position.head<2>() - rear_attractor).squaredNorm() - a.perimeter.flow_width < - (b.position.head<2>() - rear_attractor).squaredNorm(); + return a.position.y() + SeamPlacer::seam_align_score_tolerance * 5.0f > b.position.y(); } float penalty_a = a.overhang + a.visibility @@ -1382,15 +1379,19 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const SeamPlacerImpl:: observations[index] = current.position.head<2>(); observation_points[index] = current.position.z(); weights[index] = angle_weight(current.local_ccw_angle); - float sign = layer_angle > 2.0 * std::abs(current.local_ccw_angle) ? -0.8f : 1.0f; + float curling_influence = layer_angle > 2.0 * std::abs(current.local_ccw_angle) ? -0.8f : 1.0f; if (current.type == EnforcedBlockedSeamPoint::Enforced) { - sign = 1.0f; + curling_influence = 1.0f; weights[index] += 3.0f; } - total_length += sign * (last_point_pos - current.position).norm(); + total_length += curling_influence * (last_point_pos - current.position).norm(); last_point_pos = current.position; } + if (comparator.setup == spRear) { + total_length *= 0.3f; + } + // Curve Fitting size_t number_of_segments = std::max(size_t(1), size_t(std::max(0.0f,total_length) / SeamPlacer::seam_align_mm_per_segment)); @@ -1457,9 +1458,7 @@ void SeamPlacer::init(const Print &print, std::function throw_if_can for (const PrintObject *po : print.objects()) { throw_if_canceled_func(); SeamPosition configured_seam_preference = po->config().seam_position.value; - Vec2f rear_attractor = unscaled(po->bounding_box().center()).cast() + - 1.5f * Vec2f(0.0f, unscale(po->bounding_box().max.y())); - SeamComparator comparator{configured_seam_preference, rear_attractor}; + SeamComparator comparator { configured_seam_preference }; { GlobalModelInfo global_model_info { }; From 70be93d1126cb088f07da7146ddff31449c44db6 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 23 Sep 2022 10:46:43 +0200 Subject: [PATCH 17/17] Fixed issue with Euler angles: the function to extract Euler angles did not work reliably in some of the corner cases. The bug was not present in 2.5.0 release. --- src/libslic3r/Geometry.cpp | 61 +++++++------------------- src/libslic3r/Geometry.hpp | 4 +- src/libslic3r/Model.cpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoScale.cpp | 2 +- src/slic3r/GUI/Selection.cpp | 8 ++-- tests/libslic3r/test_geometry.cpp | 24 ++++++++++ 6 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/libslic3r/Geometry.cpp b/src/libslic3r/Geometry.cpp index 621289a61..a5aaa3899 100644 --- a/src/libslic3r/Geometry.cpp +++ b/src/libslic3r/Geometry.cpp @@ -374,46 +374,17 @@ Transform3d scale_transform(const Vec3d& scale) return transform; } -Vec3d extract_euler_angles(const Eigen::Matrix& rotation_matrix) +Vec3d extract_rotation(const Eigen::Matrix& rotation_matrix) { - // reference: http://eecs.qmul.ac.uk/~gslabaugh/publications/euler.pdf - Vec3d angles1 = Vec3d::Zero(); - Vec3d angles2 = Vec3d::Zero(); - if (std::abs(std::abs(rotation_matrix(2, 0)) - 1.0) < 1e-5) { - angles1.z() = 0.0; - if (rotation_matrix(2, 0) < 0.0) { // == -1.0 - angles1.y() = 0.5 * double(PI); - angles1.x() = angles1.z() + ::atan2(rotation_matrix(0, 1), rotation_matrix(0, 2)); - } - else { // == 1.0 - angles1.y() = - 0.5 * double(PI); - angles1.x() = - angles1.y() + ::atan2(- rotation_matrix(0, 1), - rotation_matrix(0, 2)); - } - angles2 = angles1; - } - else { - angles1.y() = -::asin(rotation_matrix(2, 0)); - const double inv_cos1 = 1.0 / ::cos(angles1.y()); - angles1.x() = ::atan2(rotation_matrix(2, 1) * inv_cos1, rotation_matrix(2, 2) * inv_cos1); - angles1.z() = ::atan2(rotation_matrix(1, 0) * inv_cos1, rotation_matrix(0, 0) * inv_cos1); - - angles2.y() = double(PI) - angles1.y(); - const double inv_cos2 = 1.0 / ::cos(angles2.y()); - angles2.x() = ::atan2(rotation_matrix(2, 1) * inv_cos2, rotation_matrix(2, 2) * inv_cos2); - angles2.z() = ::atan2(rotation_matrix(1, 0) * inv_cos2, rotation_matrix(0, 0) * inv_cos2); - } - - // The following euristic is the best found up to now (in the sense that it works fine with the greatest number of edge use-cases) - // but there are other use-cases were it does not - // We need to improve it - const double min_1 = angles1.cwiseAbs().minCoeff(); - const double min_2 = angles2.cwiseAbs().minCoeff(); - const bool use_1 = (min_1 < min_2) || (is_approx(min_1, min_2) && (angles1.norm() <= angles2.norm())); - - return use_1 ? angles1 : angles2; + // The extracted "rotation" is a triplet of numbers such that Geometry::rotation_transform + // returns the original transform. Because of the chosen order of rotations, the triplet + // is not equivalent to Euler angles in the usual sense. + Vec3d angles = rotation_matrix.eulerAngles(2,1,0); + std::swap(angles(0), angles(2)); + return angles; } -Vec3d extract_euler_angles(const Transform3d& transform) +Vec3d extract_rotation(const Transform3d& transform) { // use only the non-translational part of the transform Eigen::Matrix m = transform.matrix().block(0, 0, 3, 3); @@ -421,7 +392,7 @@ Vec3d extract_euler_angles(const Transform3d& transform) m.col(0).normalize(); m.col(1).normalize(); m.col(2).normalize(); - return extract_euler_angles(m); + return extract_rotation(m); } #if ENABLE_WORLD_COORDINATE @@ -430,7 +401,7 @@ Transform3d Transformation::get_offset_matrix() const return assemble_transform(get_offset()); } -static Transform3d extract_rotation(const Transform3d& trafo) +static Transform3d extract_rotation_matrix(const Transform3d& trafo) { Matrix3d rotation; Matrix3d scale; @@ -464,12 +435,12 @@ static bool contains_skew(const Transform3d& trafo) Vec3d Transformation::get_rotation() const { - return extract_euler_angles(extract_rotation(m_matrix)); + return extract_rotation(extract_rotation_matrix(m_matrix)); } Transform3d Transformation::get_rotation_matrix() const { - return extract_rotation(m_matrix); + return extract_rotation_matrix(m_matrix); } #else bool Transformation::Flags::needs_update(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const @@ -532,7 +503,7 @@ void Transformation::set_rotation(Axis axis, double rotation) #if ENABLE_WORLD_COORDINATE auto [curr_rotation, scale] = extract_rotation_scale(m_matrix); - Vec3d angles = extract_euler_angles(curr_rotation); + Vec3d angles = extract_rotation(curr_rotation); angles[axis] = rotation; const Vec3d offset = get_offset(); @@ -569,7 +540,7 @@ void Transformation::set_scaling_factor(const Vec3d& scaling_factor) assert(scaling_factor.x() > 0.0 && scaling_factor.y() > 0.0 && scaling_factor.z() > 0.0); const Vec3d offset = get_offset(); - m_matrix = extract_rotation(m_matrix) * scale_transform(scaling_factor); + m_matrix = extract_rotation_matrix(m_matrix) * scale_transform(scaling_factor); m_matrix.translation() = offset; #else set_scaling_factor(X, scaling_factor.x()); @@ -704,7 +675,7 @@ void Transformation::set_from_transform(const Transform3d& transform) m3x3.col(2).normalize(); // rotation - set_rotation(extract_euler_angles(m3x3)); + set_rotation(extract_rotation(m3x3)); // forces matrix recalculation matrix m_matrix = get_matrix(); @@ -833,7 +804,7 @@ Transformation Transformation::volume_to_bed_transformation(const Transformation for (int i = 0; i < 3; ++i) scale(i) = pts.col(i).dot(qs.col(i)) / pts.col(i).dot(pts.col(i)); - out.set_rotation(Geometry::extract_euler_angles(volume_rotation_trafo)); + out.set_rotation(Geometry::extract_rotation(volume_rotation_trafo)); out.set_scaling_factor(Vec3d(std::abs(scale.x()), std::abs(scale.y()), std::abs(scale.z()))); out.set_mirror(Vec3d(scale.x() > 0 ? 1. : -1, scale.y() > 0 ? 1. : -1, scale.z() > 0 ? 1. : -1)); } diff --git a/src/libslic3r/Geometry.hpp b/src/libslic3r/Geometry.hpp index d0ae84d86..495b88c17 100644 --- a/src/libslic3r/Geometry.hpp +++ b/src/libslic3r/Geometry.hpp @@ -375,11 +375,11 @@ Transform3d scale_transform(const Vec3d& scale); // Returns the euler angles extracted from the given rotation matrix // Warning -> The matrix should not contain any scale or shear !!! -Vec3d extract_euler_angles(const Eigen::Matrix& rotation_matrix); +Vec3d extract_rotation(const Eigen::Matrix& rotation_matrix); // Returns the euler angles extracted from the given affine transform // Warning -> The transform should not contain any shear !!! -Vec3d extract_euler_angles(const Transform3d& transform); +Vec3d extract_rotation(const Transform3d& transform); class Transformation { diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 97d8ea04b..9a2a0bb83 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1917,7 +1917,7 @@ void ModelVolume::rotate(double angle, Axis axis) void ModelVolume::rotate(double angle, const Vec3d& axis) { - set_rotation(get_rotation() + Geometry::extract_euler_angles(Eigen::Quaterniond(Eigen::AngleAxisd(angle, axis)).toRotationMatrix())); + set_rotation(get_rotation() + Geometry::extract_rotation(Eigen::Quaterniond(Eigen::AngleAxisd(angle, axis)).toRotationMatrix())); } void ModelVolume::mirror(Axis axis) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 0f68cb761..572e011e5 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -285,7 +285,7 @@ void GLGizmoScale3D::on_render() #else m_bounding_box = v.bounding_box(); m_transform = v.world_matrix(); - angles = Geometry::extract_euler_angles(m_transform); + angles = Geometry::extract_rotation(m_transform); // consider rotation+mirror only components of the transform for offsets offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v.get_instance_mirror()); m_offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), v.get_volume_rotation(), Vec3d::Ones(), v.get_volume_mirror()); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 0b2a13040..c6ddd1fa3 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -958,7 +958,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ else { // extracts rotations from the composed transformation const Vec3d new_rotation = transformation_type.world() ? - Geometry::extract_euler_angles(Geometry::assemble_transform(Vec3d::Zero(), rotation) * m_cache.volumes_data[i].get_instance_rotation_matrix()) : + Geometry::extract_rotation(Geometry::assemble_transform(Vec3d::Zero(), rotation) * m_cache.volumes_data[i].get_instance_rotation_matrix()) : transformation_type.absolute() ? rotation : rotation + m_cache.volumes_data[i].get_instance_rotation(); if (rot_axis_max == 2 && transformation_type.joint()) { // Only allow rotation of multiple instances as a single rigid body when rotating around the Z axis. @@ -979,7 +979,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ v.set_volume_rotation(m_cache.volumes_data[i].get_volume_rotation() + rotation); else { const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation); - const Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix()); + const Vec3d new_rotation = Geometry::extract_rotation(m * m_cache.volumes_data[i].get_volume_rotation_matrix()); v.set_volume_rotation(new_rotation); } } @@ -989,7 +989,7 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_ else if (m_mode == Volume) { // extracts rotations from the composed transformation const Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation); - const Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix()); + const Vec3d new_rotation = Geometry::extract_rotation(m * m_cache.volumes_data[i].get_volume_rotation_matrix()); if (transformation_type.joint()) { const Vec3d local_pivot = m_cache.volumes_data[i].get_instance_full_matrix().inverse() * m_cache.dragging_center; const Vec3d offset = m * (m_cache.volumes_data[i].get_volume_position() - local_pivot); @@ -1050,7 +1050,7 @@ void Selection::flattening_rotate(const Vec3d& normal) voldata.get_instance_scaling_factor().cwiseInverse(), voldata.get_instance_mirror()) * normal).normalized(); // Additional rotation to align tnormal with the down vector in the world coordinate space. auto extra_rotation = Eigen::Quaterniond().setFromTwoVectors(tnormal, -Vec3d::UnitZ()); - v.set_instance_rotation(Geometry::extract_euler_angles(extra_rotation.toRotationMatrix() * m_cache.volumes_data[i].get_instance_rotation_matrix())); + v.set_instance_rotation(Geometry::extract_rotation(extra_rotation.toRotationMatrix() * m_cache.volumes_data[i].get_instance_rotation_matrix())); #endif // ENABLE_WORLD_COORDINATE } diff --git a/tests/libslic3r/test_geometry.cpp b/tests/libslic3r/test_geometry.cpp index 41ef69aaa..239edd4f7 100644 --- a/tests/libslic3r/test_geometry.cpp +++ b/tests/libslic3r/test_geometry.cpp @@ -764,3 +764,27 @@ TEST_CASE("Convex polygon intersection test prusa polygons", "[Geometry][Rotcali REQUIRE(res == ref); } } + + +TEST_CASE("Euler angles roundtrip", "[Geometry]") { + std::vector euler_angles_vec = {{M_PI/2., -M_PI, 0.}, + {M_PI, -M_PI, 0.}, + {M_PI, -M_PI, 2*M_PI}, + {0., 0., M_PI}, + {M_PI, M_PI/2., 0.}, + {0.2, 0.3, -0.5}}; + + // Also include all combinations of zero and +-pi/2: + for (double x : {0., M_PI/2., -M_PI/2.}) + for (double y : {0., M_PI/2., -M_PI/2.}) + for (double z : {0., M_PI/2., -M_PI/2.}) + euler_angles_vec.emplace_back(x, y, z); + + for (Vec3d& euler_angles : euler_angles_vec) { + Transform3d trafo1 = Geometry::rotation_transform(euler_angles); + euler_angles = Geometry::extract_rotation(trafo1); + Transform3d trafo2 = Geometry::rotation_transform(euler_angles); + + REQUIRE(trafo1.isApprox(trafo2)); + } +}