Follow-up to f342bfae4e
as GCC did not like what MSVC was able to swallow.
This commit is contained in:
parent
fcb00680ab
commit
f24b4e86a9
@ -2204,7 +2204,6 @@ LayerResult GCode::process_layer(
|
||||
m_avoid_crossing_perimeters.disable_once();
|
||||
}
|
||||
|
||||
|
||||
std::vector<InstanceToPrint> instances_to_print = sort_print_object_instances(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):
|
||||
|
@ -187,6 +187,21 @@ void ToolOrdering::initialize_layers(std::vector<coordf_t> &zs)
|
||||
}
|
||||
}
|
||||
|
||||
// Decides whether this entity could be overridden
|
||||
static [[nodiscard]] bool is_overriddable(const ExtrusionEntityCollection& eec, const LayerTools& lt, const PrintConfig& print_config, const PrintObject& object, const PrintRegion& region)
|
||||
{
|
||||
if (print_config.filament_soluble.get_at(lt.extruder(eec, region)))
|
||||
return false;
|
||||
|
||||
if (object.config().wipe_into_objects)
|
||||
return true;
|
||||
|
||||
if (!region.config().wipe_into_infill || eec.role() != erInternalInfill)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Collect extruders reuqired to print layers.
|
||||
void ToolOrdering::collect_extruders(const PrintObject &object, const std::vector<std::pair<double, unsigned int>> &per_layer_extruder_switches)
|
||||
{
|
||||
@ -232,7 +247,7 @@ void ToolOrdering::collect_extruders(const PrintObject &object, const std::vecto
|
||||
if (m_print_config_ptr) { // in this case complete_objects is false (see ToolOrdering constructors)
|
||||
something_nonoverriddable = false;
|
||||
for (const ExtrusionEntity *eec : layerm->perimeters()) // let's check if there are nonoverriddable entities
|
||||
if (layer_tools.wiping_extrusions().is_overriddable(dynamic_cast<const ExtrusionEntityCollection&>(*eec), *m_print_config_ptr, object, region))
|
||||
if (is_overriddable(dynamic_cast<const ExtrusionEntityCollection&>(*eec), layer_tools, *m_print_config_ptr, object, region))
|
||||
layer_tools.wiping_extrusions_nonconst().set_something_overridable();
|
||||
else
|
||||
something_nonoverriddable = true;
|
||||
@ -257,7 +272,7 @@ void ToolOrdering::collect_extruders(const PrintObject &object, const std::vecto
|
||||
has_infill = true;
|
||||
|
||||
if (m_print_config_ptr) {
|
||||
if (layer_tools.wiping_extrusions().is_overriddable(*fill, *m_print_config_ptr, object, region))
|
||||
if (is_overriddable(*fill, layer_tools, *m_print_config_ptr, object, region))
|
||||
layer_tools.wiping_extrusions_nonconst().set_something_overridable();
|
||||
else
|
||||
something_nonoverriddable = true;
|
||||
@ -599,12 +614,6 @@ const LayerTools& ToolOrdering::tools_for_layer(coordf_t print_z) const
|
||||
return *it_layer_tools;
|
||||
}
|
||||
|
||||
static const LayerTools& layer_tools(const WipingExtrusions *self)
|
||||
{
|
||||
char *ptr = (char*)(self) - offsetof(LayerTools, m_wiping_extrusions);
|
||||
return *reinterpret_cast<const LayerTools*>(ptr);
|
||||
}
|
||||
|
||||
// This function is called from Print::mark_wiping_extrusions and sets extruder this entity should be printed with (-1 .. as usual)
|
||||
void WipingExtrusions::set_extruder_override(const ExtrusionEntity* entity, size_t copy_id, int extruder, size_t num_of_copies)
|
||||
{
|
||||
@ -622,9 +631,9 @@ void WipingExtrusions::set_extruder_override(const ExtrusionEntity* entity, size
|
||||
}
|
||||
|
||||
// Finds first non-soluble extruder on the layer
|
||||
int WipingExtrusions::first_nonsoluble_extruder_on_layer(const PrintConfig& print_config) const
|
||||
static [[nodiscard]] int first_nonsoluble_extruder_on_layer(const PrintConfig& print_config, const LayerTools& layer_tools)
|
||||
{
|
||||
for (auto extruders_it = layer_tools(this).extruders.begin(); extruders_it != layer_tools(this).extruders.end(); ++extruders_it)
|
||||
for (auto extruders_it = layer_tools.extruders.begin(); extruders_it != layer_tools.extruders.end(); ++extruders_it)
|
||||
if (!print_config.filament_soluble.get_at(*extruders_it))
|
||||
return (*extruders_it);
|
||||
|
||||
@ -632,36 +641,20 @@ int WipingExtrusions::first_nonsoluble_extruder_on_layer(const PrintConfig& prin
|
||||
}
|
||||
|
||||
// Finds last non-soluble extruder on the layer
|
||||
int WipingExtrusions::last_nonsoluble_extruder_on_layer(const PrintConfig& print_config) const
|
||||
static [[nodiscard]] int last_nonsoluble_extruder_on_layer(const PrintConfig& print_config, const LayerTools& layer_tools)
|
||||
{
|
||||
for (auto extruders_it = layer_tools(this).extruders.rbegin(); extruders_it != layer_tools(this).extruders.rend(); ++extruders_it)
|
||||
for (auto extruders_it = layer_tools.extruders.rbegin(); extruders_it != layer_tools.extruders.rend(); ++extruders_it)
|
||||
if (!print_config.filament_soluble.get_at(*extruders_it))
|
||||
return (*extruders_it);
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
// Decides whether this entity could be overridden
|
||||
bool WipingExtrusions::is_overriddable(const ExtrusionEntityCollection& eec, const PrintConfig& print_config, const PrintObject& object, const PrintRegion& region) const
|
||||
{
|
||||
if (print_config.filament_soluble.get_at(layer_tools(this).extruder(eec, region)))
|
||||
return false;
|
||||
|
||||
if (object.config().wipe_into_objects)
|
||||
return true;
|
||||
|
||||
if (!region.config().wipe_into_infill || eec.role() != erInternalInfill)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Following function iterates through all extrusions on the layer, remembers those that could be used for wiping after toolchange
|
||||
// and returns volume that is left to be wiped on the wipe tower.
|
||||
// Switching from old_extruder to new_extruder, trying to wipe volume_to_wipe into not yet extruded extrusions, that may change material (overridable).
|
||||
float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int old_extruder, unsigned int new_extruder, float volume_to_wipe)
|
||||
float WipingExtrusions::mark_wiping_extrusions(const Print& print, const LayerTools <, unsigned int old_extruder, unsigned int new_extruder, float volume_to_wipe)
|
||||
{
|
||||
const LayerTools& lt = layer_tools(this);
|
||||
const float min_infill_volume = 0.f; // ignore infill with smaller volume than this
|
||||
|
||||
if (! m_something_overridable || volume_to_wipe <= 0. ||
|
||||
@ -710,7 +703,7 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int
|
||||
for (const ExtrusionEntity* ee : layerm->fills()) { // iterate through all infill Collections
|
||||
auto* fill = dynamic_cast<const ExtrusionEntityCollection*>(ee);
|
||||
|
||||
if (!is_overriddable(*fill, print.config(), *object, region))
|
||||
if (!is_overriddable(*fill, lt, print.config(), *object, region))
|
||||
continue;
|
||||
|
||||
if (wipe_into_infill_only && ! print.config().infill_first)
|
||||
@ -733,7 +726,7 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int
|
||||
{
|
||||
for (const ExtrusionEntity* ee : layerm->perimeters()) {
|
||||
auto* fill = dynamic_cast<const ExtrusionEntityCollection*>(ee);
|
||||
if (is_overriddable(*fill, print.config(), *object, region) && !is_entity_overridden(fill, copy) && fill->total_volume() > min_infill_volume) {
|
||||
if (is_overriddable(*fill, lt, print.config(), *object, region) && !is_entity_overridden(fill, copy) && fill->total_volume() > min_infill_volume) {
|
||||
set_extruder_override(fill, copy, new_extruder, num_of_copies);
|
||||
if ((volume_to_wipe -= float(fill->total_volume())) <= 0.f)
|
||||
// More material was purged already than asked for.
|
||||
@ -755,14 +748,13 @@ float WipingExtrusions::mark_wiping_extrusions(const Print& print, unsigned int
|
||||
// that were not actually overridden. If they are part of a dedicated object, printing them with the extruder
|
||||
// they were initially assigned to might mean violating the perimeter-infill order. We will therefore go through
|
||||
// them again and make sure we override it.
|
||||
void WipingExtrusions::ensure_perimeters_infills_order(const Print& print)
|
||||
void WipingExtrusions::ensure_perimeters_infills_order(const Print& print, const LayerTools <)
|
||||
{
|
||||
if (! m_something_overridable)
|
||||
return;
|
||||
|
||||
const LayerTools& lt = layer_tools(this);
|
||||
unsigned int first_nonsoluble_extruder = first_nonsoluble_extruder_on_layer(print.config());
|
||||
unsigned int last_nonsoluble_extruder = last_nonsoluble_extruder_on_layer(print.config());
|
||||
unsigned int first_nonsoluble_extruder = first_nonsoluble_extruder_on_layer(print.config(), lt);
|
||||
unsigned int last_nonsoluble_extruder = last_nonsoluble_extruder_on_layer(print.config(), lt);
|
||||
|
||||
for (const PrintObject* object : print.objects()) {
|
||||
// Finds this layer:
|
||||
@ -780,7 +772,7 @@ void WipingExtrusions::ensure_perimeters_infills_order(const Print& print)
|
||||
for (const ExtrusionEntity* ee : layerm->fills()) { // iterate through all infill Collections
|
||||
auto* fill = dynamic_cast<const ExtrusionEntityCollection*>(ee);
|
||||
|
||||
if (!is_overriddable(*fill, print.config(), *object, region)
|
||||
if (!is_overriddable(*fill, lt, print.config(), *object, region)
|
||||
|| is_entity_overridden(fill, copy) )
|
||||
continue;
|
||||
|
||||
@ -802,7 +794,7 @@ void WipingExtrusions::ensure_perimeters_infills_order(const Print& print)
|
||||
// Now the same for perimeters - see comments above for explanation:
|
||||
for (const ExtrusionEntity* ee : layerm->perimeters()) { // iterate through all perimeter Collections
|
||||
auto* fill = dynamic_cast<const ExtrusionEntityCollection*>(ee);
|
||||
if (is_overriddable(*fill, print.config(), *object, region) && ! is_entity_overridden(fill, copy))
|
||||
if (is_overriddable(*fill, lt, print.config(), *object, region) && ! is_entity_overridden(fill, copy))
|
||||
set_extruder_override(fill, copy, (print.config().infill_first ? last_nonsoluble_extruder : first_nonsoluble_extruder), num_of_copies);
|
||||
}
|
||||
}
|
||||
|
@ -42,17 +42,13 @@ public:
|
||||
|
||||
// This function goes through all infill entities, decides which ones will be used for wiping and
|
||||
// marks them by the extruder id. Returns volume that remains to be wiped on the wipe tower:
|
||||
float mark_wiping_extrusions(const Print& print, unsigned int old_extruder, unsigned int new_extruder, float volume_to_wipe);
|
||||
float mark_wiping_extrusions(const Print& print, const LayerTools& lt, unsigned int old_extruder, unsigned int new_extruder, float volume_to_wipe);
|
||||
|
||||
void ensure_perimeters_infills_order(const Print& print);
|
||||
void ensure_perimeters_infills_order(const Print& print, const LayerTools& lt);
|
||||
|
||||
bool is_overriddable(const ExtrusionEntityCollection& ee, const PrintConfig& print_config, const PrintObject& object, const PrintRegion& region) const;
|
||||
void set_something_overridable() { m_something_overridable = true; }
|
||||
|
||||
private:
|
||||
int first_nonsoluble_extruder_on_layer(const PrintConfig& print_config) const;
|
||||
int last_nonsoluble_extruder_on_layer(const PrintConfig& print_config) const;
|
||||
|
||||
// This function is called from mark_wiping_extrusions and sets extruder that it should be printed with (-1 .. as usual)
|
||||
void set_extruder_override(const ExtrusionEntity* entity, size_t copy_id, int extruder, size_t num_of_copies);
|
||||
|
||||
@ -115,9 +111,6 @@ private:
|
||||
friend class ToolOrdering;
|
||||
LayerTools(const coordf_t z) : print_z(z) {}
|
||||
|
||||
// for calculating offset of m_wiping_extrusions in LayerTools.
|
||||
friend const LayerTools& layer_tools(const WipingExtrusions *self);
|
||||
|
||||
// This object holds list of extrusion that will be used for extruder wiping
|
||||
WipingExtrusions m_wiping_extrusions;
|
||||
};
|
||||
|
@ -1208,7 +1208,7 @@ void Print::_make_wipe_tower()
|
||||
volume_to_wipe -= (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id);
|
||||
|
||||
// try to assign some infills/objects for the wiping:
|
||||
volume_to_wipe = layer_tools.wiping_extrusions_nonconst().mark_wiping_extrusions(*this, current_extruder_id, extruder_id, volume_to_wipe);
|
||||
volume_to_wipe = layer_tools.wiping_extrusions_nonconst().mark_wiping_extrusions(*this, layer_tools, current_extruder_id, extruder_id, volume_to_wipe);
|
||||
|
||||
// add back the minimal amount toforce on the wipe tower:
|
||||
volume_to_wipe += (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id);
|
||||
@ -1219,7 +1219,7 @@ void Print::_make_wipe_tower()
|
||||
current_extruder_id = extruder_id;
|
||||
}
|
||||
}
|
||||
layer_tools.wiping_extrusions_nonconst().ensure_perimeters_infills_order(*this);
|
||||
layer_tools.wiping_extrusions_nonconst().ensure_perimeters_infills_order(*this, layer_tools);
|
||||
if (&layer_tools == &m_wipe_tower_data.tool_ordering.back() || (&layer_tools + 1)->wipe_tower_partitions == 0)
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user