Skip to content

Commit

Permalink
Added a single perimeter to the first layer of support or raft.
Browse files Browse the repository at this point in the history
Fixes [Request] Add optional perimeter to raft #756
Fixes First support layer does not stick to bed #2101

New parameters raft_first_layer_density and raft_first_layer_expansion
to influence the 1st layer of raft or support.
Fixes Allow to disable raft under support structures. #3772
Fixes raft is larger than necessary #2568
Fixes Supports on the build plate should have a solid bottom interface for better adhesion #1165

Changed the 1st layer infill to rectilinear even for soluble materials.
Fixes first layer of support for multi filament support oddly spaced #1445
Fixes Full Soluble Materials interfacing into Models + Soluble material noise on Bed #684
  • Loading branch information
bubnikv committed Feb 24, 2021
1 parent 77d007c commit fcb714c
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 80 deletions.
14 changes: 14 additions & 0 deletions src/libslic3r/ExtrusionEntity.hpp
Expand Up @@ -102,6 +102,7 @@ class ExtrusionEntity
virtual double min_mm3_per_mm() const = 0;
virtual Polyline as_polyline() const = 0;
virtual void collect_polylines(Polylines &dst) const = 0;
virtual void collect_points(Points &dst) const = 0;
virtual Polylines as_polylines() const { Polylines dst; this->collect_polylines(dst); return dst; }
virtual double length() const = 0;
virtual double total_volume() const = 0;
Expand Down Expand Up @@ -167,6 +168,7 @@ class ExtrusionPath : public ExtrusionEntity
double min_mm3_per_mm() const override { return this->mm3_per_mm; }
Polyline as_polyline() const override { return this->polyline; }
void collect_polylines(Polylines &dst) const override { if (! this->polyline.empty()) dst.emplace_back(this->polyline); }
void collect_points(Points &dst) const override { append(dst, this->polyline.points); }
double total_volume() const override { return mm3_per_mm * unscale<double>(length()); }

private:
Expand Down Expand Up @@ -217,6 +219,12 @@ class ExtrusionMultiPath : public ExtrusionEntity
double min_mm3_per_mm() const override;
Polyline as_polyline() const override;
void collect_polylines(Polylines &dst) const override { Polyline pl = this->as_polyline(); if (! pl.empty()) dst.emplace_back(std::move(pl)); }
void collect_points(Points &dst) const override {
size_t n = std::accumulate(paths.begin(), paths.end(), 0, [](const size_t n, const ExtrusionPath &p){ return n + p.polyline.size(); });
dst.reserve(dst.size() + n);
for (const ExtrusionPath &p : this->paths)
append(dst, p.polyline.points);
}
double total_volume() const override { double volume =0.; for (const auto& path : paths) volume += path.total_volume(); return volume; }
};

Expand Down Expand Up @@ -268,6 +276,12 @@ class ExtrusionLoop : public ExtrusionEntity
double min_mm3_per_mm() const override;
Polyline as_polyline() const override { return this->polygon().split_at_first_point(); }
void collect_polylines(Polylines &dst) const override { Polyline pl = this->as_polyline(); if (! pl.empty()) dst.emplace_back(std::move(pl)); }
void collect_points(Points &dst) const override {
size_t n = std::accumulate(paths.begin(), paths.end(), 0, [](const size_t n, const ExtrusionPath &p){ return n + p.polyline.size(); });
dst.reserve(dst.size() + n);
for (const ExtrusionPath &p : this->paths)
append(dst, p.polyline.points);
}
double total_volume() const override { double volume =0.; for (const auto& path : paths) volume += path.total_volume(); return volume; }

//static inline std::string role_to_string(ExtrusionLoopRole role);
Expand Down
5 changes: 5 additions & 0 deletions src/libslic3r/ExtrusionEntityCollection.hpp
Expand Up @@ -117,6 +117,11 @@ class ExtrusionEntityCollection : public ExtrusionEntity
extrusion_entity->collect_polylines(dst);
}

void collect_points(Points &dst) const override {
for (ExtrusionEntity* extrusion_entity : this->entities)
extrusion_entity->collect_points(dst);
}

double length() const override {
throw Slic3r::RuntimeError("Calling length() on a ExtrusionEntityCollection");
return 0.;
Expand Down
12 changes: 9 additions & 3 deletions src/libslic3r/GCode.cpp
Expand Up @@ -2573,10 +2573,11 @@ std::string GCode::extrude_infill(const Print &print, const std::vector<ObjectBy

std::string GCode::extrude_support(const ExtrusionEntityCollection &support_fills)
{
static constexpr const char *support_label = "support material";
static constexpr const char *support_interface_label = "support material interface";

std::string gcode;
if (! support_fills.entities.empty()) {
const char *support_label = "support material";
const char *support_interface_label = "support material interface";
const double support_speed = m_config.support_material_speed.value;
const double support_interface_speed = m_config.support_material_interface_speed.get_abs_value(support_speed);
for (const ExtrusionEntity *ee : support_fills.entities) {
Expand All @@ -2589,9 +2590,14 @@ std::string GCode::extrude_support(const ExtrusionEntityCollection &support_fill
gcode += this->extrude_path(*path, label, speed);
else {
const ExtrusionMultiPath *multipath = dynamic_cast<const ExtrusionMultiPath*>(ee);
assert(multipath != nullptr);
if (multipath)
gcode += this->extrude_multi_path(*multipath, label, speed);
else {
const ExtrusionEntityCollection *eec = dynamic_cast<const ExtrusionEntityCollection*>(ee);
assert(eec);
if (eec)
gcode += this->extrude_support(*eec);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/libslic3r/Preset.cpp
Expand Up @@ -426,7 +426,8 @@ const std::vector<std::string>& Preset::print_options()
"bridge_speed", "gap_fill_speed", "gap_fill_enabled", "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", "brim_offset", "brim_type", "support_material", "support_material_auto", "support_material_threshold", "support_material_enforce_layers",
"raft_layers", "support_material_pattern", "support_material_with_sheath", "support_material_spacing",
"raft_layers", "raft_first_layer_density", "raft_first_layer_expansion",
"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",
Expand Down
3 changes: 1 addition & 2 deletions src/libslic3r/Print.cpp
Expand Up @@ -1731,8 +1731,7 @@ void Print::_make_skirt()
for (const SupportLayer *layer : object->support_layers()) {
if (layer->print_z > skirt_height_z)
break;
for (const ExtrusionEntity *extrusion_entity : layer->support_fills.entities)
append(object_points, extrusion_entity->as_polyline().points);
layer->support_fills.collect_points(object_points);
}
// Repeat points for each object copy.
for (const PrintInstance &instance : object->instances()) {
Expand Down
19 changes: 19 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Expand Up @@ -1775,6 +1775,25 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionString(""));
def->cli = ConfigOptionDef::nocli;

def = this->add("raft_first_layer_density", coPercent);
def->label = L("First layer density");
def->category = L("Support material");
def->tooltip = L("Density of the first raft or support layer.");
def->sidetext = L("%");
def->min = 0;
def->max = 150;
def->mode = comExpert;
def->set_default_value(new ConfigOptionPercent(90));

def = this->add("raft_first_layer_expansion", coFloat);
def->label = L("First layer expansion");
def->category = L("Support material");
def->tooltip = L("Expansion of the first raft or support layer to improve adhesion to print bed.");
def->sidetext = L("mm");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(3.));

def = this->add("raft_layers", coInt);
def->label = L("Raft layers");
def->category = L("Support material");
Expand Down
4 changes: 4 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Expand Up @@ -473,6 +473,8 @@ class PrintObjectConfig : public StaticPrintConfig
// Force the generation of solid shells between adjacent materials/volumes.
ConfigOptionBool interface_shells;
ConfigOptionFloat layer_height;
ConfigOptionPercent raft_first_layer_density;
ConfigOptionFloat raft_first_layer_expansion;
ConfigOptionInt raft_layers;
ConfigOptionEnum<SeamPosition> seam_position;
// ConfigOptionFloat seam_preferred_direction;
Expand Down Expand Up @@ -520,6 +522,8 @@ class PrintObjectConfig : public StaticPrintConfig
OPT_PTR(infill_only_where_needed);
OPT_PTR(interface_shells);
OPT_PTR(layer_height);
OPT_PTR(raft_first_layer_density);
OPT_PTR(raft_first_layer_expansion);
OPT_PTR(raft_layers);
OPT_PTR(seam_position);
OPT_PTR(slice_closing_radius);
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/PrintObject.cpp
Expand Up @@ -576,6 +576,8 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "support_material_synchronize_layers"
|| opt_key == "support_material_threshold"
|| opt_key == "support_material_with_sheath"
|| opt_key == "raft_first_layer_density"
|| opt_key == "raft_first_layer_expansion"
|| opt_key == "dont_support_bridges"
|| opt_key == "first_layer_extrusion_width") {
steps.emplace_back(posSupportMaterial);
Expand Down

1 comment on commit fcb714c

@TimmyOl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of prusaslicer Will this commit be merged into?

Please sign in to comment.