From 69aae4a2ad4be803b9622a3c2718ec7d3f8dbbb3 Mon Sep 17 00:00:00 2001 From: nemart69 <78763471+nemart69@users.noreply.github.com> Date: Tue, 9 Feb 2021 21:15:33 +0100 Subject: [PATCH] Raft changes, libslic3r part --- src/libslic3r/PerimeterGenerator.cpp | 5 +++- src/libslic3r/Preset.cpp | 5 ++-- src/libslic3r/PrintConfig.cpp | 42 ++++++++++++++++++++++++++++ src/libslic3r/PrintConfig.hpp | 25 +++++++++++++++++ src/libslic3r/PrintObject.cpp | 15 ++++++++-- src/libslic3r/Slicing.cpp | 31 ++++++++++---------- src/libslic3r/SupportMaterial.cpp | 19 ++++++++++--- 7 files changed, 118 insertions(+), 24 deletions(-) diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index ba12a1edbbf..b209e85b8e3 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -153,7 +153,10 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime // detect overhanging/bridging perimeters ExtrusionPaths paths; - if (perimeter_generator.config->overhangs && perimeter_generator.layer_id > 0 + if ( ( (perimeter_generator.config->overhangs && perimeter_generator.layer_id > perimeter_generator.object_config->raft_layers) + || (perimeter_generator.object_config->raft_overhangs + && perimeter_generator.object_config->raft_layers > 0 + && perimeter_generator.layer_id == perimeter_generator.object_config->raft_layers)) // RaftingEdition && !(perimeter_generator.object_config->support_material && perimeter_generator.object_config->support_material_contact_distance.value == 0)) { // get non-overhang paths by intersecting this loop with the grown lower slices extrusion_paths_append( diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index c24033df203..c2ff343bbcd 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -419,8 +419,9 @@ const std::vector& Preset::print_options() "bridge_speed", "gap_fill_speed", "travel_speed", "first_layer_speed", "perimeter_acceleration", "infill_acceleration", "bridge_acceleration", "first_layer_acceleration", "default_acceleration", "skirts", "skirt_distance", "skirt_height", "draft_shield", "min_skirt_length", "brim_width", "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_synchronize_layers", "support_material_angle", "support_material_interface_layers", + "raft_layers", "raft_overhangs", "raft_contact_distance", "raft_xy_size_compensation", "raft_size_adjust", + "support_material_pattern", "support_material_with_sheath", + "support_material_spacing", "support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers", "support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance", "support_material_buildplate_only", "dont_support_bridges", "notes", "complete_objects", "extruder_clearance_radius", "extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "perimeter_extruder", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b3084f55012..242a5aec52b 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1720,6 +1720,48 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionInt(0)); + // RaftingEdition + def = this->add("raft_overhangs", coBool); + def->label = L("Bridge flow above raft"); + def->category = L("Support material"); + def->tooltip = L("Use bridge flow and speed for the bottom layer. Quality of the layer improves significantly when this setting is off, however it could be difficult to remove the object from raft. Ignored for soluble interface."); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionBool(false)); + + def = this->add("raft_contact_distance", coFloat); + def->label = L("Raft contact Z distance"); + def->category = L("Support material"); + def->tooltip = L("The vertical distance between object and raft. Ignored for soluble interface."); + def->sidetext = L("mm"); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloat(0.1)); + + def = this->add("raft_xy_size_compensation", coFloat); + def->label = L("Bottom layer expansion"); + def->category = L("Support material"); + def->tooltip = L("XY plane expansion of the bottom layer. This is useful to compensate shrinking, especially for higher contact Z distances and / or specific materials."); + def->sidetext = L("mm"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(0.0)); + + def = this->add("raft_size_adjust", coEnum); + def->label = L("Raft size"); + def->category = L("Support material"); + def->tooltip = L("Raft size adjustment. Can be used to improve adhesion or reduce material consumption / save some printing area."); + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values.push_back("small"); + def->enum_values.push_back("normal"); + def->enum_values.push_back("large"); + def->enum_values.push_back("extralarge"); + def->enum_labels.push_back("Small"); + def->enum_labels.push_back("Normal"); + def->enum_labels.push_back("Large"); + def->enum_labels.push_back("Extra large"); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionEnum(rsaNormal)); + def = this->add("resolution", coFloat); def->label = L("Resolution"); def->tooltip = L("Minimum detail resolution, used to simplify the input file for speeding up " diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index b5896891ef9..de804e5a5fc 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -82,6 +82,13 @@ enum SLAPillarConnectionMode { slapcmDynamic }; +enum RaftSizeAdjust { + rsaSmall, + rsaNormal, + rsaLarge, + rsaExtraLarge +}; + template<> inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { static t_config_enum_values keys_map; if (keys_map.empty()) { @@ -214,6 +221,16 @@ template<> inline const t_config_enum_values& ConfigOptionEnum inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { + static const t_config_enum_values keys_map = { + { "small", rsaSmall }, + { "normal", rsaNormal }, + { "large", rsaLarge }, + { "extralarge", rsaExtraLarge } + }; + + return keys_map; +} // Defines each and every confiuration option of Slic3r, including the properties of the GUI dialogs. // Does not store the actual values, but defines default values. class PrintConfigDef : public ConfigDef @@ -437,6 +454,10 @@ class PrintObjectConfig : public StaticPrintConfig ConfigOptionBool interface_shells; ConfigOptionFloat layer_height; ConfigOptionInt raft_layers; + ConfigOptionBool raft_overhangs; + ConfigOptionFloat raft_contact_distance; + ConfigOptionFloat raft_xy_size_compensation; + ConfigOptionEnum raft_size_adjust; ConfigOptionEnum seam_position; // ConfigOptionFloat seam_preferred_direction; // ConfigOptionFloat seam_preferred_direction_jitter; @@ -481,6 +502,10 @@ class PrintObjectConfig : public StaticPrintConfig OPT_PTR(interface_shells); OPT_PTR(layer_height); OPT_PTR(raft_layers); + OPT_PTR(raft_overhangs); + OPT_PTR(raft_contact_distance); + OPT_PTR(raft_xy_size_compensation); + OPT_PTR(raft_size_adjust); OPT_PTR(seam_position); OPT_PTR(slice_closing_radius); // OPT_PTR(seam_preferred_direction); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 99b4130f4ca..56df4787612 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -530,6 +530,10 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector& range) { // If we have raft layers, consider bottom layer as a bridge just like any other bottom surface lying on the void. SurfaceType surface_type_bottom_1st = - (m_config.raft_layers.value > 0 && m_config.support_material_contact_distance.value > 0) ? + (m_config.raft_layers.value > 0 && m_config.support_material_contact_distance.value > 0 && + /* RaftingEdition */ m_config.raft_overhangs.value) ? stBottomBridge : stBottom; // If we have soluble support material, don't bridge. The overhang will be squished against a soluble layer separating // the support from the print. @@ -1920,7 +1925,10 @@ void PrintObject::_slice(const std::vector &layer_height_profile) BOOST_LOG_TRIVIAL(debug) << "Slicing objects - make_slices in parallel - begin"; { // Compensation value, scaled. - const float xy_compensation_scaled = float(scale_(m_config.xy_size_compensation.value)); + const float _xy_compensation_scaled = float(scale_(m_config.xy_size_compensation.value)); + const float _xy_compensation_1st_scaled = _xy_compensation_scaled + (m_config.raft_layers > 0) ? + // Apply optional compensation / expand the first layer above the raft. (RaftingEdition) + float(scale_(m_config.raft_xy_size_compensation.value)) : 0.f; const float elephant_foot_compensation_scaled = (m_config.raft_layers == 0) ? // Only enable Elephant foot compensation if printing directly on the print bed. float(scale_(m_config.elefant_foot_compensation.value)) : @@ -1929,13 +1937,14 @@ void PrintObject::_slice(const std::vector &layer_height_profile) ExPolygons lslices_1st_layer; tbb::parallel_for( tbb::blocked_range(0, m_layers.size()), - [this, upscaled, clipped, xy_compensation_scaled, elephant_foot_compensation_scaled, &lslices_1st_layer] + [this, upscaled, clipped, _xy_compensation_scaled, _xy_compensation_1st_scaled, elephant_foot_compensation_scaled, &lslices_1st_layer] (const tbb::blocked_range& range) { for (size_t layer_id = range.begin(); layer_id < range.end(); ++ layer_id) { m_print->throw_if_canceled(); Layer *layer = m_layers[layer_id]; // Apply size compensation and perform clipping of multi-part objects. float elfoot = (layer_id == 0) ? elephant_foot_compensation_scaled : 0.f; + float xy_compensation_scaled = (layer_id == 0) ? _xy_compensation_1st_scaled : _xy_compensation_scaled; // RaftingEdition if (layer->m_regions.size() == 1) { assert(! upscaled); assert(! clipped); diff --git a/src/libslic3r/Slicing.cpp b/src/libslic3r/Slicing.cpp index 16068dde442..95fa4c9d082 100644 --- a/src/libslic3r/Slicing.cpp +++ b/src/libslic3r/Slicing.cpp @@ -110,8 +110,9 @@ SlicingParameters SlicingParameters::create_from_config( params.min_layer_height = std::min(params.min_layer_height, params.layer_height); params.max_layer_height = std::max(params.max_layer_height, params.layer_height); + // RaftingEdition: independent contact distance for raft, first object layer height not messed up if (! soluble_interface) { - params.gap_raft_object = object_config.support_material_contact_distance.value; + params.gap_raft_object = object_config.raft_contact_distance.value; params.gap_object_support = object_config.support_material_contact_distance.value; params.gap_support_object = object_config.support_material_contact_distance.value; } @@ -127,16 +128,18 @@ SlicingParameters SlicingParameters::create_from_config( #if 1 params.contact_raft_layer_height = std::max(params.layer_height, 0.75 * support_material_interface_extruder_dmr); if (! soluble_interface) { - // Compute the average of all nozzles used for printing the object over a raft. - //FIXME It is expected, that the 1st layer of the object is printed with a bridging flow over a full raft. Shall it not be vice versa? - coordf_t average_object_extruder_dmr = 0.; - if (! object_extruders.empty()) { - for (unsigned int extruder_id : object_extruders) - average_object_extruder_dmr += print_config.nozzle_diameter.get_at(extruder_id); - average_object_extruder_dmr /= coordf_t(object_extruders.size()); + if (object_config.raft_overhangs.value) { + // Compute the average of all nozzles used for printing the object over a raft. + //FIXME It is expected, that the 1st layer of the object is printed with a bridging flow over a full raft. Shall it not be vice versa? + coordf_t average_object_extruder_dmr = 0.; + if (! object_extruders.empty()) { + for (unsigned int extruder_id : object_extruders) + average_object_extruder_dmr += print_config.nozzle_diameter.get_at(extruder_id); + average_object_extruder_dmr /= coordf_t(object_extruders.size()); + } + params.first_object_layer_height = average_object_extruder_dmr; + params.first_object_layer_bridging = true; } - params.first_object_layer_height = average_object_extruder_dmr; - params.first_object_layer_bridging = true; } #else params.contact_raft_layer_height = soluble_interface ? support_material_interface_extruder_dmr : 0.75 * support_material_interface_extruder_dmr; @@ -150,13 +153,13 @@ SlicingParameters SlicingParameters::create_from_config( //FIXME The last raft layer is the contact layer, which shall be printed with a bridging flow for ease of separation. Currently it is not the case. if (params.raft_layers() == 1) { // There is only the contact layer. - params.contact_raft_layer_height = first_layer_height; - params.raft_contact_top_z = first_layer_height; + params.first_print_layer_height = params.contact_raft_layer_height; + params.raft_contact_top_z = params.contact_raft_layer_height; } else { assert(params.base_raft_layers > 0); assert(params.interface_raft_layers > 0); - // Number of the base raft layers is decreased by the first layer. - params.raft_base_top_z = first_layer_height + coordf_t(params.base_raft_layers - 1) * params.base_raft_layer_height; + params.first_print_layer_height = params.base_raft_layer_height; + params.raft_base_top_z = coordf_t(params.base_raft_layers) * params.base_raft_layer_height; // Number of the interface raft layers is decreased by the contact layer. params.raft_interface_top_z = params.raft_base_top_z + coordf_t(params.interface_raft_layers - 1) * params.interface_raft_layer_height; params.raft_contact_top_z = params.raft_interface_top_z + params.contact_raft_layer_height; diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index 95c4297542b..0098570da25 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -1040,8 +1040,17 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_ // we're here just to get the object footprint for the raft. // We only consider contours and discard holes to get a more continuous raft. overhang_polygons = collect_slices_outer(layer); - // Extend by SUPPORT_MATERIAL_MARGIN, which is 1.5mm - contact_polygons = offset(overhang_polygons, scale_(SUPPORT_MATERIAL_MARGIN)); + // RaftingEdition + float adjust; + switch (m_object_config->raft_size_adjust.value) { + case rsaSmall: adjust = scale_(SUPPORT_MATERIAL_MARGIN / 2); break; + default: + case rsaNormal: adjust = scale_(SUPPORT_MATERIAL_MARGIN * 1); break; + case rsaLarge: adjust = scale_(SUPPORT_MATERIAL_MARGIN * 3); break; + case rsaExtraLarge: adjust = scale_(SUPPORT_MATERIAL_MARGIN * 4); break; + } + // Extend by a multiple of SUPPORT_MATERIAL_MARGIN, which is 1.5mm + contact_polygons = offset(overhang_polygons, adjust); } else { // Generate overhang / contact_polygons for non-raft layers. const Layer &lower_layer = *object.layers()[layer_id-1]; @@ -1829,7 +1838,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int assert(extr2z > extr1z || (extr1 != nullptr && extr2->layer_type == sltBottomContact)); if (std::abs(extr1z) < EPSILON) { // This layer interval starts with the 1st layer. Print the 1st layer using the prescribed 1st layer thickness. - assert(! m_slicing_params.has_raft()); + // assert(! m_slicing_params.has_raft()); RaftingEdition: unclear where the issue is: assert fails with 1-layer raft & base supports assert(intermediate_layers.empty() || intermediate_layers.back()->print_z <= m_slicing_params.first_print_layer_height); // At this point only layers above first_print_layer_heigth + EPSILON are expected as the other cases were captured earlier. assert(extr2z >= m_slicing_params.first_print_layer_height + EPSILON); @@ -2157,7 +2166,9 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf { // How much to inflate the support columns to be stable. This also applies to the 1st layer, if no raft layers are to be printed. const float inflate_factor_fine = float(scale_((m_slicing_params.raft_layers() > 1) ? 0.5 : EPSILON)); - const float inflate_factor_1st_layer = float(scale_(3.)) - inflate_factor_fine; + const float inflate_factor_1st_layer = float(scale_((m_slicing_params.raft_layers() > 0 && + m_object_config->raft_size_adjust.value == rsaSmall) ? + 1.5 /* RaftingEdition */ : 3.)) - inflate_factor_fine; MyLayer *contacts = top_contacts .empty() ? nullptr : top_contacts .front(); MyLayer *interfaces = interface_layers.empty() ? nullptr : interface_layers.front(); MyLayer *columns_base = base_layers .empty() ? nullptr : base_layers .front();