mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-08 22:29:10 +08:00
Further optimizations of G-Code generator when Wipe into object / infill:
Don't do unnecessary tests if it is known that there is no Wipe into object or infill active.
This commit is contained in:
parent
e0811e4aa5
commit
3e0690b37b
@ -1947,6 +1947,7 @@ void GCode::process_layer(
|
|||||||
|
|
||||||
// Group extrusions by an extruder, then by an object, an island and a region.
|
// Group extrusions by an extruder, then by an object, an island and a region.
|
||||||
std::map<unsigned int, std::vector<ObjectByExtruder>> by_extruder;
|
std::map<unsigned int, std::vector<ObjectByExtruder>> by_extruder;
|
||||||
|
bool is_anything_overridden = const_cast<LayerTools&>(layer_tools).wiping_extrusions().is_anything_overridden();
|
||||||
for (const LayerToPrint &layer_to_print : layers) {
|
for (const LayerToPrint &layer_to_print : layers) {
|
||||||
if (layer_to_print.support_layer != nullptr) {
|
if (layer_to_print.support_layer != nullptr) {
|
||||||
const SupportLayer &support_layer = *layer_to_print.support_layer;
|
const SupportLayer &support_layer = *layer_to_print.support_layer;
|
||||||
@ -2048,27 +2049,29 @@ void GCode::process_layer(
|
|||||||
int correct_extruder_id = Print::get_extruder(*extrusions, region);
|
int correct_extruder_id = Print::get_extruder(*extrusions, region);
|
||||||
|
|
||||||
// Let's recover vector of extruder overrides:
|
// Let's recover vector of extruder overrides:
|
||||||
const WipingExtrusions::ExtruderPerCopy *entity_overrides = const_cast<LayerTools&>(layer_tools).wiping_extrusions().get_extruder_overrides(extrusions, correct_extruder_id, layer_to_print.object()->copies().size());
|
const WipingExtrusions::ExtruderPerCopy *entity_overrides = nullptr;
|
||||||
printing_extruders.clear();
|
if (is_anything_overridden) {
|
||||||
if (entity_overrides == nullptr) {
|
printing_extruders.clear();
|
||||||
printing_extruders.emplace_back(correct_extruder_id);
|
if (! layer_tools.has_extruder(correct_extruder_id)) {
|
||||||
} else {
|
// this entity is not overridden, but its extruder is not in layer_tools - we'll print it
|
||||||
printing_extruders.reserve(entity_overrides->size() + 1);
|
// by last extruder on this layer (could happen e.g. when a wiping object is taller than others - dontcare extruders are eradicated from layer_tools)
|
||||||
for (int extruder : *entity_overrides)
|
correct_extruder_id = layer_tools.extruders.back();
|
||||||
printing_extruders.emplace_back(extruder >= 0 ?
|
}
|
||||||
// at least one copy is overridden to use this extruder
|
entity_overrides = const_cast<LayerTools&>(layer_tools).wiping_extrusions().get_extruder_overrides(extrusions, correct_extruder_id, layer_to_print.object()->copies().size());
|
||||||
extruder :
|
if (entity_overrides == nullptr) {
|
||||||
// at least one copy would normally be printed with this extruder (see get_extruder_overrides function for explanation)
|
printing_extruders.emplace_back(correct_extruder_id);
|
||||||
static_cast<unsigned int>(- extruder - 1));
|
} else {
|
||||||
}
|
printing_extruders.reserve(entity_overrides->size());
|
||||||
if (! layer_tools.has_extruder(correct_extruder_id)) {
|
for (int extruder : *entity_overrides)
|
||||||
// this entity is not overridden, but its extruder is not in layer_tools - we'll print it
|
printing_extruders.emplace_back(extruder >= 0 ?
|
||||||
// by last extruder on this layer (could happen e.g. when a wiping object is taller than others - dontcare extruders are eradicated from layer_tools)
|
// at least one copy is overridden to use this extruder
|
||||||
printing_extruders.emplace_back(layer_tools.extruders.back());
|
extruder :
|
||||||
}
|
// at least one copy would normally be printed with this extruder (see get_extruder_overrides function for explanation)
|
||||||
Slic3r::sort_remove_duplicates(printing_extruders);
|
static_cast<unsigned int>(- extruder - 1));
|
||||||
if (printing_extruders.size() == 1 && printing_extruders.front() == correct_extruder_id)
|
}
|
||||||
entity_overrides = nullptr;
|
Slic3r::sort_remove_duplicates(printing_extruders);
|
||||||
|
} else
|
||||||
|
printing_extruders = { correct_extruder_id };
|
||||||
|
|
||||||
// Now we must add this extrusion into the by_extruder map, once for each extruder that will print it:
|
// Now we must add this extrusion into the by_extruder map, once for each extruder that will print it:
|
||||||
for (unsigned int extruder : printing_extruders)
|
for (unsigned int extruder : printing_extruders)
|
||||||
@ -2157,7 +2160,6 @@ void GCode::process_layer(
|
|||||||
std::vector<InstanceToPrint> instances_to_print = sort_print_object_instances(objects_by_extruder_it->second, layers, ordering, single_object_instance_idx);
|
std::vector<InstanceToPrint> instances_to_print = sort_print_object_instances(objects_by_extruder_it->second, layers, ordering, single_object_instance_idx);
|
||||||
|
|
||||||
// We are almost ready to print. However, we must go through all the objects twice to print the the overridden extrusions first (infill/perimeter wiping feature):
|
// We are almost ready to print. However, we must go through all the objects twice to print the the overridden extrusions first (infill/perimeter wiping feature):
|
||||||
bool is_anything_overridden = const_cast<LayerTools&>(layer_tools).wiping_extrusions().is_anything_overridden();
|
|
||||||
std::vector<ObjectByExtruder::Island::Region> by_region_per_copy_cache;
|
std::vector<ObjectByExtruder::Island::Region> by_region_per_copy_cache;
|
||||||
for (int print_wipe_extrusions = is_anything_overridden; print_wipe_extrusions>=0; --print_wipe_extrusions) {
|
for (int print_wipe_extrusions = is_anything_overridden; print_wipe_extrusions>=0; --print_wipe_extrusions) {
|
||||||
if (is_anything_overridden && print_wipe_extrusions == 0)
|
if (is_anything_overridden && print_wipe_extrusions == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user