From f5dd32d96931c5c1920351dca70353fb8b830077 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 19 Aug 2020 15:22:02 +0200 Subject: [PATCH] #287 filament shrinkage compensation --- resources/ui_layout/filament.ui | 17 +++++++++-------- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 13 ++++++++++++- src/libslic3r/PrintConfig.hpp | 2 ++ src/libslic3r/PrintObject.cpp | 18 ++++++++++++++++++ src/slic3r/GUI/Preset.cpp | 1 + 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/resources/ui_layout/filament.ui b/resources/ui_layout/filament.ui index 29b0fbc25..6ee4794fc 100644 --- a/resources/ui_layout/filament.ui +++ b/resources/ui_layout/filament.ui @@ -16,6 +16,14 @@ group:Temperature °C setting:label:Other layers:bed_temperature end_line setting:chamber_temperature +group:Filament properties + setting:width$7:filament_type + setting:filament_soluble + setting:filament_shrink +group:Print speed override + setting:filament_max_wipe_tower_speed + setting:filament_max_volumetric_speed + volumetric_speed_description page:Cooling:time group:Fan speed - default @@ -35,10 +43,7 @@ group:Very short layer time - began to decrease extrusion rate group:Behavior cooling_description -page:Advanced:wrench -group:Filament properties - setting:width$7:filament_type - setting:filament_soluble +page:Multimaterial:funnel group:Multimaterial toolchange temperature setting:filament_enable_toolchange_temp setting:filament_toolchange_temp @@ -52,10 +57,6 @@ group:Multimaterial toolchange string reduction setting:filament_cooling_zone_pause setting:filament_dip_insertion_speed setting:filament_dip_extraction_speed -group:Print speed override - setting:filament_max_wipe_tower_speed - setting:filament_max_volumetric_speed - volumetric_speed_description group:Wipe tower parameters setting:filament_minimal_purge_on_wipe_tower group:Toolchange parameters with single extruder MM printers diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index ede8a8c06..1a614ab48 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -203,6 +203,7 @@ bool Print::invalidate_state_by_config_options(const std::vectortooltip = L("Enter your filament diameter here. Good precision is required, so use a caliper " "and do multiple measurements along the filament, then compute the average."); def->sidetext = L("mm"); - def->min = 0; + def->min = 0; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloats{ 1.75 }); + def = this->add("filament_shrink", coPercents); + def->label = L("Shrikage"); + def->tooltip = L("Enter the shrinkage percentage that the filament will get after cooling (94% if you measure 94mm instead of 100mm)." + " The part will be scaled in xy to conpensate." + " Only the filament used for the perimeter is taken into account." + "\nBe sure to let enough space between objects, as this compensation is done after the checks."); + def->sidetext = L("%"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionPercents{ 100 }); + def = this->add("filament_density", coFloats); def->label = L("Density"); def->tooltip = L("Enter your filament density here. This is only for statistical information. " diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 1286cb92d..c0c45f873 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1065,6 +1065,7 @@ public: ConfigOptionInts fan_below_layer_time; ConfigOptionStrings filament_colour; ConfigOptionStrings filament_notes; + ConfigOptionPercents filament_shrink; ConfigOptionFloat first_layer_acceleration; ConfigOptionInts first_layer_bed_temperature; ConfigOptionFloatOrPercent first_layer_extrusion_width; @@ -1156,6 +1157,7 @@ protected: OPT_PTR(fan_below_layer_time); OPT_PTR(filament_colour); OPT_PTR(filament_notes); + OPT_PTR(filament_shrink); OPT_PTR(first_layer_acceleration); OPT_PTR(first_layer_bed_temperature); OPT_PTR(first_layer_extrusion_width); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 53d20a2e2..0c0f2690f 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -2161,6 +2161,14 @@ void PrintObject::_slice(const std::vector &layer_height_profile) BOOST_LOG_TRIVIAL(debug) << "Slicing objects - region " << region_id; // slicing in parallel std::vector expolygons_by_layer = this->slice_region(region_id, slice_zs, slicing_mode); + //scale for shrinkage + double scale = print()->config().filament_shrink.get_abs_value(this->print()->regions()[region_id]->extruder(FlowRole::frPerimeter) - 1, 1); + if (scale != 1) { + scale = 1 / scale; + for (ExPolygons &polys : expolygons_by_layer) + for (ExPolygon &poly : polys) + poly.scale(scale); + } m_print->throw_if_canceled(); BOOST_LOG_TRIVIAL(debug) << "Slicing objects - append slices " << region_id << " start"; for (size_t layer_id = 0; layer_id < expolygons_by_layer.size(); ++ layer_id) @@ -2204,6 +2212,16 @@ void PrintObject::_slice(const std::vector &layer_height_profile) ++ i; } } + //scale for shrinkage + for (SlicedVolume &sv : sliced_volumes) { + double scale = print()->config().filament_shrink.get_abs_value(this->print()->regions()[sv.region_id]->extruder(FlowRole::frPerimeter) - 1, 1); + if (scale != 1) { + scale = 1 / scale; + for (ExPolygons &polys : sv.expolygons_by_layer) + for (ExPolygon &poly : polys) + poly.scale(scale); + } + } // Second clip the volumes in the order they are presented at the user interface. BOOST_LOG_TRIVIAL(debug) << "Slicing objects - parallel clipping - start"; tbb::parallel_for( diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index bcd7926d5..d89f66843 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -559,6 +559,7 @@ const std::vector& Preset::filament_options() "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time", "filament_unloading_speed", "filament_toolchange_delay", "filament_unloading_speed_start", "filament_unload_time", "filament_cooling_moves", "filament_cooling_initial_speed", "filament_cooling_final_speed", "filament_ramming_parameters", "filament_minimal_purge_on_wipe_tower", + "filament_shrink", "filament_use_skinnydip", // skinnydip params start "filament_use_fast_skinnydip", "filament_skinnydip_distance",