Skip to content

Commit

Permalink
Raft changes, libslic3r part
Browse files Browse the repository at this point in the history
  • Loading branch information
nemart69 authored Feb 9, 2021
1 parent fcabe8a commit 69aae4a
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 24 deletions.
5 changes: 4 additions & 1 deletion src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,9 @@ const std::vector<std::string>& 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",
Expand Down
42 changes: 42 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RaftSizeAdjust>::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<RaftSizeAdjust>(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 "
Expand Down
25 changes: 25 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ enum SLAPillarConnectionMode {
slapcmDynamic
};

enum RaftSizeAdjust {
rsaSmall,
rsaNormal,
rsaLarge,
rsaExtraLarge
};

template<> inline const t_config_enum_values& ConfigOptionEnum<PrinterTechnology>::get_enum_values() {
static t_config_enum_values keys_map;
if (keys_map.empty()) {
Expand Down Expand Up @@ -214,6 +221,16 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<SLAPillarConnecti
return keys_map;
}

template<> inline const t_config_enum_values& ConfigOptionEnum<RaftSizeAdjust>::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
Expand Down Expand Up @@ -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<RaftSizeAdjust> raft_size_adjust;
ConfigOptionEnum<SeamPosition> seam_position;
// ConfigOptionFloat seam_preferred_direction;
// ConfigOptionFloat seam_preferred_direction_jitter;
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 12 additions & 3 deletions src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_
opt_key == "layer_height"
|| opt_key == "first_layer_height"
|| opt_key == "raft_layers"
|| opt_key == "raft_overhangs"
|| opt_key == "raft_contact_distance"
|| opt_key == "raft_xy_size_compensation"
|| opt_key == "raft_size_adjust"
|| opt_key == "slice_closing_radius") {
steps.emplace_back(posSlice);
} else if (
Expand Down Expand Up @@ -751,7 +755,8 @@ void PrintObject::detect_surfaces_type()
[this, idx_region, interface_shells, &surfaces_new](const tbb::blocked_range<size_t>& 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.
Expand Down Expand Up @@ -1920,7 +1925,10 @@ void PrintObject::_slice(const std::vector<coordf_t> &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)) :
Expand All @@ -1929,13 +1937,14 @@ void PrintObject::_slice(const std::vector<coordf_t> &layer_height_profile)
ExPolygons lslices_1st_layer;
tbb::parallel_for(
tbb::blocked_range<size_t>(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<size_t>& 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);
Expand Down
31 changes: 17 additions & 14 deletions src/libslic3r/Slicing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand Down
19 changes: 15 additions & 4 deletions src/libslic3r/SupportMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 69aae4a

Please sign in to comment.