From 436bdac624590a8675c07cb6872ed34a06a0fbae Mon Sep 17 00:00:00 2001 From: supermerill Date: Tue, 26 Jun 2018 20:01:37 +0200 Subject: [PATCH] gui switchs : enforce 100% fill volume --- xs/src/libslic3r/Fill/Fill.cpp | 15 ++------------- xs/src/libslic3r/Fill/FillBase.cpp | 2 +- xs/src/libslic3r/Fill/FillBase.hpp | 4 ++++ xs/src/libslic3r/Fill/FillSmooth.cpp | 16 ++++++++++------ xs/src/libslic3r/PrintConfig.cpp | 11 +++++++++-- xs/src/libslic3r/PrintConfig.hpp | 2 ++ xs/src/libslic3r/PrintObject.cpp | 1 + xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 7 ++++--- 9 files changed, 34 insertions(+), 26 deletions(-) diff --git a/xs/src/libslic3r/Fill/Fill.cpp b/xs/src/libslic3r/Fill/Fill.cpp index d6752e383..7ab8a1da4 100644 --- a/xs/src/libslic3r/Fill/Fill.cpp +++ b/xs/src/libslic3r/Fill/Fill.cpp @@ -224,23 +224,12 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out) // f->layer_height = h; //give the overlap size, it's not the real value (it can depend of the external_perimeter_extrusion_width) f->overlap = layerm.region()->config.infill_overlap.get_abs_value(flow.nozzle_diameter); - - /*printf("infill_overlap : widdth=%d scaled=%d unscaled=%d, widdth=%d scaled=%d unscaled=%d, infill_overlap=%d, absvalue_scaled=%d, absvalue_UNscaled=%d.\n", - layerm.region()->config.perimeter_extrusion_width.getFloat(), - scale_(layerm.region()->config.perimeter_extrusion_width.getFloat()), - unscale(layerm.region()->config.perimeter_extrusion_width.getFloat()), - layerm.flow(frPerimeter).width, - scale_(layerm.flow(frPerimeter).width), - unscale(layerm.flow(frPerimeter).width), - layerm.region()->config.infill_overlap.getFloat(), - layerm.region()->config.infill_overlap.get_abs_value(layerm.region()->config.perimeter_extrusion_width), - f->overlap);*/ - // apply half spacing using this flow's own spacing and generate infill FillParams params; params.density = 0.01 * density; -// params.dont_adjust = true; params.dont_adjust = false; + params.fill_exactly = layerm.region()->config.enforce_full_fill_volume.getBool(); + // calculate actual flow from spacing (which might have been adjusted by the infill // pattern generator) diff --git a/xs/src/libslic3r/Fill/FillBase.cpp b/xs/src/libslic3r/Fill/FillBase.cpp index 0fc6a3051..604943914 100644 --- a/xs/src/libslic3r/Fill/FillBase.cpp +++ b/xs/src/libslic3r/Fill/FillBase.cpp @@ -141,7 +141,7 @@ void Fill::fill_surface_extrusion(const Surface *surface, const FillParams ¶ return; // ensure it doesn't over or under-extrude double multFlow = 1; - if (!params.dont_adjust && params.density == 1 && !flow.bridge){ + if (!params.dont_adjust && params.full_infill() && !flow.bridge && params.fill_exactly){ // compute the path of the nozzle -> extruded volume double lengthTot = 0; int nbLines = 0; diff --git a/xs/src/libslic3r/Fill/FillBase.hpp b/xs/src/libslic3r/Fill/FillBase.hpp index f0666bb74..512996cd1 100644 --- a/xs/src/libslic3r/Fill/FillBase.hpp +++ b/xs/src/libslic3r/Fill/FillBase.hpp @@ -22,6 +22,7 @@ struct FillParams // Adjustment does not work. dont_adjust = true; flow_mult = 1.f; + fill_exactly = false; } bool full_infill() const { return density > 0.9999f; } @@ -38,6 +39,9 @@ struct FillParams // Don't adjust spacing to fill the space evenly. bool dont_adjust; + // Try to extrude the exact amount of plastic to fill the volume requested + bool fill_exactly; + // For Honeycomb. // we were requested to complete each loop; // in this case we don't try to make more continuous paths diff --git a/xs/src/libslic3r/Fill/FillSmooth.cpp b/xs/src/libslic3r/Fill/FillSmooth.cpp index ed3b68980..ad359b2ee 100644 --- a/xs/src/libslic3r/Fill/FillSmooth.cpp +++ b/xs/src/libslic3r/Fill/FillSmooth.cpp @@ -35,7 +35,7 @@ namespace Slic3r { //a small under-overlap to prevent over-extrudion on thin surfaces (i.e. remove the overlap) Surface surfaceNoOverlap(*surface); //remove the overlap (prevent over-extruding) if possible - ExPolygons noOffsetPolys = offset2_ex(surfaceNoOverlap.expolygon, -scale_(this->overlap) * 1, 0); + ExPolygons noOffsetPolys = offset2_ex(surfaceNoOverlap.expolygon, -scale_(this->overlap) * (flow.bridge?0:1), 0); //printf("FillSmooth::fill_surface() : overlap=%f->%f.\n", overlap, -scale_(this->overlap)); //printf("FillSmooth::polys : 1->%i.\n", noOffsetPolys.size()); //printf("FillSmooth::polys : %f %f->%f.\n", surface->expolygon.area(), surfaceNoOverlap.expolygon.area(), noOffsetPolys[0].area()); @@ -97,12 +97,13 @@ namespace Slic3r { double extrudedVolume = flow.mm3_per_mm() * lengthTot; volumeToOccupy += poylineVolume; - printf("FillSmooth: request extruding of %f length, with mm3_per_mm of %f =volume=> %f / %f (%f)\n", + printf("FillSmooth: request extruding of %f length, with mm3_per_mm of %f =volume=> %f / %f (%f) %s\n", lengthTot, flow.mm3_per_mm(), flow.mm3_per_mm() * lengthTot, flow.height*unscale(unscale(surfaceNoOverlap.area())), - (flow.mm3_per_mm() * lengthTot) / (flow.height*unscale(unscale(surfaceNoOverlap.area()))) + (flow.mm3_per_mm() * lengthTot) / (flow.height*unscale(unscale(surfaceNoOverlap.area()))), + params.fill_exactly ? "ready" : "only for info" ); printf("FillSmooth: extruding flow mult %f vs old: %f\n", percentFlow[0] * poylineVolume / extrudedVolume, percentFlow[0] / percentWidth[0]); @@ -113,7 +114,8 @@ namespace Slic3r { eec->entities, STDMOVE(polylines_layer1), flow.bridge ? erBridgeInfill : rolePass[0], //reduced flow height for a better view (it's only a gui thing) - params.flow_mult * flow.mm3_per_mm() * percentFlow[0] * poylineVolume / extrudedVolume, (float)flow.width*percentFlow[0] * poylineVolume / extrudedVolume, (float)flow.height*0.8); + params.flow_mult * flow.mm3_per_mm() * percentFlow[0] * (params.fill_exactly? poylineVolume / extrudedVolume : 1), + (float)(flow.width*percentFlow[0] * (params.fill_exactly ? poylineVolume / extrudedVolume : 1)), (float)flow.height*0.8); } else{ return; @@ -173,7 +175,8 @@ namespace Slic3r { eec->entities, STDMOVE(polylines_layer2), rolePass[1], //reduced flow width for a better view (it's only a gui thing) - params.flow_mult * flow.mm3_per_mm() * percentFlow[1] * volumeToOccupy / extrudedVolume, (float)flow.width*(percentFlow[1] < 0.1 ? 0.1 : percentFlow[1]), (float)flow.height); + params.flow_mult * flow.mm3_per_mm() * percentFlow[1] * (params.fill_exactly ? volumeToOccupy / extrudedVolume : 1), + (float)(flow.width*(percentFlow[1] < 0.1 ? 0.1 : percentFlow[1])), (float)flow.height); } else{ return; @@ -226,7 +229,8 @@ namespace Slic3r { eec->entities, STDMOVE(polylines_layer3), rolePass[2], //slow (if last) //reduced flow width for a better view (it's only a gui thing) - params.flow_mult * flow.mm3_per_mm() * percentFlow[2] * volumeToOccupy / extrudedVolume, (float)flow.width*(percentFlow[2] < 0.1 ? 0.1 : percentFlow[2]), (float)flow.height); + params.flow_mult * flow.mm3_per_mm() * percentFlow[2] * (params.fill_exactly ? volumeToOccupy / extrudedVolume : 1), + (float)(flow.width*(percentFlow[2] < 0.1 ? 0.1 : percentFlow[2])), (float)flow.height); } } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 33c5f088a..85a54c1cf 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -100,7 +100,7 @@ PrintConfigDef::PrintConfigDef() def->cli = "bridge-fan-speed=i@"; def->min = 0; def->max = 100; - def->default_value = new ConfigOptionInts { 100 }; + def->default_value = new ConfigOptionInts{ 100 }; def = this->add("bridge_flow_ratio", coFloat); def->label = L("Bridge flow ratio"); @@ -326,6 +326,13 @@ PrintConfigDef::PrintConfigDef() def->enum_labels.push_back("Octagram Spiral"); def->default_value = new ConfigOptionEnum(ipRectilinear); + def = this->add("enforce_full_fill_volume", coBool); + def->label = L("Enforce full fill volume"); + def->category = L("Infill"); + def->tooltip = L("Experimental option wich modify (top/bottom) fill flow to have the exact amount of plastic inside the volume to fill."); + def->cli = "enforce-full-fill-volume!"; + def->default_value = new ConfigOptionBool(true); + def = this->add("external_perimeter_extrusion_width", coFloatOrPercent); def->label = L("External perimeters"); def->category = L("Extrusion Width"); @@ -364,7 +371,7 @@ PrintConfigDef::PrintConfigDef() "is supported."); def->cli = "extra-perimeters!"; def->default_value = new ConfigOptionBool(true); - + def = this->add("only_one_perimeter_top", coBool); def->label = "Only one perimeter on Top surfaces"; def->category = "Layers and Perimeters"; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index f75e9baf8..0c244a3f8 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -391,6 +391,7 @@ public: ConfigOptionBool ensure_vertical_shell_thickness; ConfigOptionEnum top_fill_pattern; ConfigOptionEnum bottom_fill_pattern; + ConfigOptionBool enforce_full_fill_volume; ConfigOptionFloatOrPercent external_perimeter_extrusion_width; ConfigOptionFloatOrPercent external_perimeter_speed; ConfigOptionBool external_perimeters_first; @@ -432,6 +433,7 @@ protected: OPT_PTR(ensure_vertical_shell_thickness); OPT_PTR(top_fill_pattern); OPT_PTR(bottom_fill_pattern); + OPT_PTR(enforce_full_fill_volume); OPT_PTR(external_perimeter_extrusion_width); OPT_PTR(external_perimeter_speed); OPT_PTR(external_perimeters_first); diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index 3ae38ea04..c4bf255ba 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -201,6 +201,7 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector& Preset::print_options() "ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width", "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width", "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", - "over_bridge_flow_ratio", "clip_multipart_objects", + "over_bridge_flow_ratio", "clip_multipart_objects", "enforce_full_fill_volume", "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", "only_one_perimeter_top", "compatible_printers", "compatible_printers_condition","inherits" }; diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index b426472eb..361acc340 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -851,6 +851,7 @@ void TabPrint::build() optgroup->append_single_option_line("fill_pattern"); optgroup->append_single_option_line("top_fill_pattern"); optgroup->append_single_option_line("bottom_fill_pattern"); + optgroup->append_single_option_line("enforce_full_fill_volume"); optgroup = page->new_optgroup(_(L("Reducing printing time"))); optgroup->append_single_option_line("infill_every_layers"); @@ -1190,8 +1191,8 @@ void TabPrint::update() bool have_solid_infill = m_config->opt_int("top_solid_layers") > 0 || m_config->opt_int("bottom_solid_layers") > 0; // solid_infill_extruder uses the same logic as in Print::extruders() - for (auto el : {"top_fill_pattern", "bottom_fill_pattern", "infill_first", "solid_infill_extruder", - "solid_infill_extrusion_width", "solid_infill_speed" }) + for (auto el : {"top_fill_pattern", "bottom_fill_pattern", "enforce_full_fill_volume", "infill_first", + "solid_infill_extruder", "solid_infill_extrusion_width", "solid_infill_speed" }) get_field(el)->toggle(have_solid_infill); for (auto el : {"fill_angle", "bridge_angle", "infill_extrusion_width", @@ -1301,7 +1302,7 @@ void TabFilament::build() line.append_option(optgroup->get_option("max_fan_speed")); optgroup->append_line(line); - optgroup->append_single_option_line("bridge_fan_speed"); + optgroup->append_single_option_line("bridge_fan_speed"); optgroup->append_single_option_line("disable_fan_first_layers"); optgroup = page->new_optgroup(_(L("Cooling thresholds")), 250);