Move infill_first from printconfig to region config (with bits from branch 'infill_first_per_region' of https://github.com/JesusFreke/Slic3r #595)

This commit is contained in:
supermerill 2018-07-26 14:51:50 +02:00
parent 5513c41a20
commit 21f56f62a8
5 changed files with 19 additions and 20 deletions

View File

@ -1477,13 +1477,9 @@ void GCode::process_layer(
for (ObjectByExtruder::Island &island : object_by_extruder.islands) {
const auto& by_region_specific = const_cast<LayerTools&>(layer_tools).wiping_extrusions().is_anything_overridden() ? island.by_region_per_copy(copy_id, extruder_id, print_wipe_extrusions) : island.by_region;
if (print.config.infill_first) {
gcode += this->extrude_infill(print, by_region_specific);
gcode += this->extrude_perimeters(print, by_region_specific, lower_layer_edge_grids[layer_id]);
} else {
gcode += this->extrude_perimeters(print, by_region_specific, lower_layer_edge_grids[layer_id]);
gcode += this->extrude_infill(print,by_region_specific);
}
gcode += this->extrude_infill(print, by_region_specific, true);
gcode += this->extrude_perimeters(print, by_region_specific, lower_layer_edge_grids[layer_id]);
gcode += this->extrude_infill(print, by_region_specific, false);
}
if (this->config().gcode_comments) {
gcode += ((std::ostringstream&)(std::ostringstream() << "; stop printing object " << print_object->model_object()->name << " id:" << layer_id << " copy " << copy_id << "\n")).str();
@ -2133,13 +2129,15 @@ std::string GCode::extrude_perimeters(const Print &print, const std::vector<Obje
}
// Chain the paths hierarchically by a greedy algorithm to minimize a travel distance.
std::string GCode::extrude_infill(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region)
std::string GCode::extrude_infill(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool is_infill_first)
{
std::string gcode;
for (const ObjectByExtruder::Island::Region &region : by_region) {
m_config.apply(print.regions[&region - &by_region.front()]->config);
ExtrusionEntityCollection chained = region.infills.chained_path_from(m_last_pos, false);
gcode += extrude_entity(chained, "infill");
if (print.regions[&region - &by_region.front()]->config.infill_first == is_infill_first) {
m_config.apply(print.regions[&region - &by_region.front()]->config);
ExtrusionEntityCollection chained = region.infills.chained_path_from(m_last_pos, false);
gcode += extrude_entity(chained, "infill");
}
}
return gcode;
}

View File

@ -238,7 +238,7 @@ protected:
std::string extrude_perimeters(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, std::unique_ptr<EdgeGrid::Grid> &lower_layer_edge_grid);
std::string extrude_infill(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region);
std::string extrude_infill(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool is_infill_first);
std::string extrude_support(const ExtrusionEntityCollection &support_fills);
std::string travel_to(const Point &point, ExtrusionRole role, std::string comment);

View File

@ -486,7 +486,7 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int
continue;
if ((!print.config.infill_first ? perimeters_done : !perimeters_done) || (!object->config.wipe_into_objects && region.config.wipe_into_infill)) {
if ((!region.config.infill_first ? perimeters_done : !perimeters_done) || (!object->config.wipe_into_objects && region.config.wipe_into_infill)) {
for (const ExtrusionEntity* ee : this_layer->regions[region_id]->fills.entities) { // iterate through all infill Collections
auto* fill = dynamic_cast<const ExtrusionEntityCollection*>(ee);
@ -499,7 +499,7 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int
if (volume_to_wipe<=0)
continue;
if (!object->config.wipe_into_objects && !print.config.infill_first && region.config.wipe_into_infill)
if (!object->config.wipe_into_objects && !region.config.infill_first && region.config.wipe_into_infill)
// In this case we must check that the original extruder is used on this layer before the one we are overridding
// (and the perimeters will be finished before the infill is printed):
if (!lt.is_extruder_order(region.config.perimeter_extruder - 1, new_extruder))
@ -513,7 +513,7 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int
}
// Now the same for perimeters - see comments above for explanation:
if (object->config.wipe_into_objects && (print.config.infill_first ? perimeters_done : !perimeters_done))
if (object->config.wipe_into_objects && (region.config.infill_first ? perimeters_done : !perimeters_done))
{
for (const ExtrusionEntity* ee : this_layer->regions[region_id]->perimeters.entities) {
auto* fill = dynamic_cast<const ExtrusionEntityCollection*>(ee);
@ -574,12 +574,12 @@ void WipingExtrusions::ensure_perimeters_infills_order(const Print& print)
// printed before its perimeter, or not be printed at all (in case its original extruder has
// not been added to LayerTools
// Either way, we will now force-override it with something suitable:
if (print.config.infill_first
if (region.config.infill_first
|| object->config.wipe_into_objects // in this case the perimeter is overridden, so we can override by the last one safely
|| lt.is_extruder_order(region.config.perimeter_extruder - 1, last_nonsoluble_extruder // !infill_first, but perimeter is already printed when last extruder prints
|| std::find(lt.extruders.begin(), lt.extruders.end(), region.config.infill_extruder - 1) == lt.extruders.end()) // we have to force override - this could violate infill_first (FIXME)
)
set_extruder_override(fill, copy, (print.config.infill_first ? first_nonsoluble_extruder : last_nonsoluble_extruder), num_of_copies);
set_extruder_override(fill, copy, (region.config.infill_first ? first_nonsoluble_extruder : last_nonsoluble_extruder), num_of_copies);
else {
// In this case we can (and should) leave it to be printed normally.
// Force overriding would mean it gets printed before its perimeter.
@ -593,7 +593,7 @@ void WipingExtrusions::ensure_perimeters_infills_order(const Print& print)
|| is_entity_overridden(fill, copy) )
continue;
set_extruder_override(fill, copy, (print.config.infill_first ? last_nonsoluble_extruder : first_nonsoluble_extruder), num_of_copies);
set_extruder_override(fill, copy, (region.config.infill_first ? last_nonsoluble_extruder : first_nonsoluble_extruder), num_of_copies);
}
}
}

View File

@ -981,6 +981,7 @@ PrintConfigDef::PrintConfigDef()
def = this->add("infill_first", coBool);
def->label = L("Infill before perimeters");
def->category = L("Infill");
def->tooltip = L("This option will switch the print order of perimeters and infill, making the latter first.");
def->cli = "infill-first!";
def->default_value = new ConfigOptionBool(false);

View File

@ -414,6 +414,7 @@ public:
ConfigOptionFloat infill_dense_angle;
ConfigOptionPercent infill_dense_density;
ConfigOptionEnum<InfillPattern> infill_dense_pattern;
ConfigOptionBool infill_first;
ConfigOptionBool overhangs;
ConfigOptionBool no_perimeter_unsupported;
ConfigOptionInt min_perimeter_unsupported;
@ -466,6 +467,7 @@ protected:
OPT_PTR(infill_dense_angle);
OPT_PTR(infill_dense_density);
OPT_PTR(infill_dense_pattern);
OPT_PTR(infill_first);
OPT_PTR(overhangs);
OPT_PTR(no_perimeter_unsupported);
OPT_PTR(min_perimeter_unsupported);
@ -692,7 +694,6 @@ public:
ConfigOptionFloatOrPercent first_layer_speed;
ConfigOptionInts first_layer_temperature;
ConfigOptionFloat infill_acceleration;
ConfigOptionBool infill_first;
ConfigOptionInts max_fan_speed;
ConfigOptionFloats max_layer_height;
ConfigOptionInts min_fan_speed;
@ -764,7 +765,6 @@ protected:
OPT_PTR(first_layer_speed);
OPT_PTR(first_layer_temperature);
OPT_PTR(infill_acceleration);
OPT_PTR(infill_first);
OPT_PTR(max_fan_speed);
OPT_PTR(max_layer_height);
OPT_PTR(min_fan_speed);