diff --git a/resources/ui_layout/print.ui b/resources/ui_layout/print.ui index f34eae9e0..344104f61 100644 --- a/resources/ui_layout/print.ui +++ b/resources/ui_layout/print.ui @@ -139,6 +139,7 @@ group:Brim setting:brim_ears setting:width$3:brim_ears_max_angle end_line + setting:brim_offset page:Support material:support group:Support material diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index c6a2f9f1d..267c16c73 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1889,24 +1889,24 @@ void Print::_make_skirt(const PrintObjectPtrs &objects, ExtrusionEntityCollectio //TODO: test if no regression vs old _make_brim. // this new one can extrude brim for an object inside an other object. ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityCollection &out) { - Flow flow = this->brim_flow(); + coord_t brim_offset = scale_(config().brim_offset.value); ExPolygons islands; for (PrintObject *object : objects) { ExPolygons object_islands; for (ExPolygon &expoly : object->m_layers.front()->lslices) if(config().brim_inside_holes || config().brim_width_interior > 0) - object_islands.push_back(expoly); + object_islands.push_back(brim_offset == 0 ? expoly : offset_ex(expoly, brim_offset)[0]); else - object_islands.emplace_back(to_expolygon(expoly.contour)); + object_islands.emplace_back(brim_offset == 0 ? to_expolygon(expoly.contour) : offset_ex(to_expolygon(expoly.contour), brim_offset)[0]); if (!object->support_layers().empty()) { Polygons polys = object->support_layers().front()->support_fills.polygons_covered_by_spacing(float(SCALED_EPSILON)); for (Polygon poly : polys) for (ExPolygon & expoly2 : union_ex(poly)) if (config().brim_inside_holes || config().brim_width_interior > 0) - object_islands.emplace_back(expoly2); + object_islands.emplace_back(brim_offset == 0 ? expoly2 : offset_ex(expoly2, brim_offset)[0]); else - object_islands.emplace_back(to_expolygon(expoly2.contour)); + object_islands.emplace_back(brim_offset == 0 ? to_expolygon(expoly2.contour) : offset_ex(to_expolygon(expoly2.contour), brim_offset)[0]); } islands.reserve(islands.size() + object_islands.size() * object->m_instances.size()); for (const PrintInstance &pt : object->m_instances) @@ -1927,7 +1927,7 @@ ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityColl unbrimmable_areas = islands; //get the brimmable area - const size_t num_loops = size_t(floor(m_config.brim_width.value / flow.spacing())); + const size_t num_loops = size_t(floor((m_config.brim_width.value - config().brim_offset.value) / flow.spacing())); ExPolygons brimmable_areas; for (ExPolygon &expoly : islands) { for (Polygon poly : offset(expoly.contour, num_loops * flow.scaled_width(), jtSquare)) { @@ -2026,22 +2026,23 @@ ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityColl ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntityCollection &out) { Flow flow = this->brim_flow(); Points pt_ears; + coord_t brim_offset = scale_(config().brim_offset.value); ExPolygons islands; for (PrintObject *object : objects) { ExPolygons object_islands; for (const ExPolygon &expoly : object->m_layers.front()->lslices) if (config().brim_inside_holes || config().brim_width_interior > 0) - object_islands.push_back(expoly); + object_islands.push_back(brim_offset==0?expoly:offset_ex(expoly, brim_offset)[0]); else - object_islands.emplace_back(to_expolygon(expoly.contour)); + object_islands.emplace_back(brim_offset == 0 ? to_expolygon(expoly.contour) : offset_ex(to_expolygon(expoly.contour), brim_offset)[0]); if (!object->support_layers().empty()) { Polygons polys = object->support_layers().front()->support_fills.polygons_covered_by_spacing(float(SCALED_EPSILON)); for (Polygon poly : polys) for (ExPolygon & expoly2 : union_ex(poly)) if (config().brim_inside_holes || config().brim_width_interior > 0) - object_islands.push_back(expoly2); + object_islands.push_back(brim_offset == 0 ? expoly2 : offset_ex(expoly2, brim_offset)[0]); else - object_islands.emplace_back(to_expolygon(expoly2.contour)); + object_islands.emplace_back(brim_offset == 0 ? to_expolygon(expoly2.contour) : offset_ex(to_expolygon(expoly2.contour), brim_offset)[0]); } islands.reserve(islands.size() + object_islands.size() * object->m_instances.size()); for (const PrintInstance ©_pt : object->m_instances) @@ -2058,7 +2059,7 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit islands = union_ex(islands, true); //get the brimmable area (for the return value only) - const size_t num_loops = size_t(floor(m_config.brim_width.value / flow.spacing())); + const size_t num_loops = size_t(floor((m_config.brim_width.value - config().brim_offset.value) / flow.spacing())); ExPolygons brimmable_areas; for (ExPolygon &expoly : islands) { for (Polygon poly : offset(expoly.contour, num_loops * flow.scaled_width(), jtSquare)) { @@ -2090,7 +2091,7 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit loops = union_pt_chained(loops, false); //create ear pattern - coord_t size_ear = (scale_(m_config.brim_width.value) - flow.scaled_spacing()); + coord_t size_ear = (scale_((m_config.brim_width.value - config().brim_offset.value)) - flow.scaled_spacing()); Polygon point_round; for (size_t i = 0; i < POLY_SIDES; i++) { double angle = (2.0 * PI * i) / POLY_SIDES; @@ -2130,16 +2131,17 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit ExPolygons Print::_make_brim_interior(const PrintObjectPtrs &objects, const ExPolygons &unbrimmable_areas, ExtrusionEntityCollection &out) { // Brim is only printed on first layer and uses perimeter extruder. Flow flow = this->brim_flow(); + coord_t brim_offset = scale_(config().brim_offset.value); ExPolygons islands; for (PrintObject *object : objects) { ExPolygons object_islands; for (ExPolygon &expoly : object->m_layers.front()->lslices) - object_islands.push_back(expoly); + object_islands.push_back(brim_offset == 0 ? expoly : offset_ex(expoly, brim_offset)[0]); if (!object->support_layers().empty()) { Polygons polys = object->support_layers().front()->support_fills.polygons_covered_by_spacing(float(SCALED_EPSILON)); for (Polygon poly : polys) for (ExPolygon & expoly2 : union_ex(poly)) - object_islands.push_back(expoly2); + object_islands.push_back(brim_offset == 0 ? expoly2 : offset_ex(expoly2, brim_offset)[0]); } islands.reserve(islands.size() + object_islands.size() * object->instances().size()); for (const PrintInstance &instance : object->instances()) @@ -2152,7 +2154,7 @@ ExPolygons Print::_make_brim_interior(const PrintObjectPtrs &objects, const ExPo islands = union_ex(islands); //to have the brimmable areas, get all holes, use them as contour , add smaller hole inside and make a diff with unbrimmable - const size_t num_loops = size_t(floor(m_config.brim_width_interior.value / flow.spacing())); + const size_t num_loops = size_t(floor((m_config.brim_width_interior.value - config().brim_offset.value) / flow.spacing())); ExPolygons brimmable_areas; Polygons islands_to_loops; for (const ExPolygon &expoly : islands) { diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 3fd9da63a..b2ffe2503 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -356,6 +356,15 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloat(125)); + def = this->add("brim_offset", coFloat); + def->label = L("brim offset"); + def->category = OptionCategory::skirtBrim; + def->tooltip = L("Distance between the brim and the part. Should be kept at 0 unless you encounter great difficulties to separate them. It's substracted to brim_width and brim_width_interior., so it has to be lower than them"); + def->sidetext = L("mm"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("chamber_temperature", coInts); def->label = L("Chamber"); def->full_label = L("Chamber temperature"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index ff3159d63..390c79ae2 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -964,6 +964,7 @@ public: ConfigOptionFloat brim_width_interior; ConfigOptionBool brim_ears; ConfigOptionFloat brim_ears_max_angle; + ConfigOptionFloat brim_offset; ConfigOptionInts chamber_temperature; ConfigOptionBool complete_objects; ConfigOptionFloats colorprint_heights; @@ -1046,6 +1047,7 @@ protected: OPT_PTR(brim_width_interior); OPT_PTR(brim_ears); OPT_PTR(brim_ears_max_angle); + OPT_PTR(brim_offset); OPT_PTR(chamber_temperature); OPT_PTR(complete_objects); OPT_PTR(colorprint_heights); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 414c80474..1fa8a1c78 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -469,6 +469,7 @@ const std::vector& Preset::print_options() "brim_width_interior", "brim_ears", "brim_ears_max_angle", + "brim_offset", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers", "raft_layers", "support_material_pattern", "support_material_with_sheath", "support_material_spacing", "support_material_interface_pattern",