Refactoring of perimeters/infills wiping (ToolOrdering::WipingExtrusions now takes care of the agenda)

Squashed commit of the following:

commit 931eb2684103e8571b4a2e9804765fef268361c3
Author: Lukas Matena <lukasmatena@seznam.cz>
Date:   Wed Jun 20 12:50:27 2018 +0200

    ToolOrdering::WipingExtrusions now holds all information necessary for infill/perimeter wiping

commit cc8becfbdd771f7e279434c8bd6be147e4b321ee
Author: Lukas Matena <lukasmatena@seznam.cz>
Date:   Tue Jun 19 10:52:03 2018 +0200

    Wiping is now done as normal print would be (less extra code in process_layer)

commit 1b120754b0691cce46ee5e10f3840480c559ac1f
Author: Lukas Matena <lukasmatena@seznam.cz>
Date:   Fri Jun 15 15:55:15 2018 +0200

    Refactoring: ObjectByExtruder changed so that it is aware of the wiping extrusions

commit 1641e326bb5e0a0c69d6bfc6efa23153dc2e4543
Author: Lukas Matena <lukasmatena@seznam.cz>
Date:   Thu Jun 14 12:22:18 2018 +0200

    Refactoring: new class WipingExtrusion in ToolOrdering.hpp
This commit is contained in:
Lukas Matena 2018-06-20 12:52:00 +02:00
parent 29dd305aaa
commit 8a47852be2
8 changed files with 301 additions and 303 deletions

View file

@ -10,6 +10,36 @@ namespace Slic3r {
class Print;
class PrintObject;
// Object of this class holds information about whether an extrusion is printed immediately
// after a toolchange (as part of infill/perimeter wiping) or not. One extrusion can be a part
// of several copies - this has to be taken into account.
class WipingExtrusions
{
public:
bool is_anything_overridden() const { // if there are no overrides, all the agenda can be skipped - this function can tell us if that's the case
return something_overridden;
}
// Returns true in case that entity is not printed with its usual extruder for a given copy:
bool is_entity_overridden(const ExtrusionEntity* entity, int copy_id) const {
return (entity_map.find(entity) == entity_map.end() ? false : entity_map.at(entity).at(copy_id) != -1);
}
// This function is called from Print::mark_wiping_extrusions and sets extruder that it should be printed with (-1 .. as usual)
void set_extruder_override(const ExtrusionEntity* entity, unsigned int copy_id, int extruder, unsigned int num_of_copies);
// This is called from GCode::process_layer - see implementation for further comments:
const std::vector<int>* get_extruder_overrides(const ExtrusionEntity* entity, int correct_extruder_id, int num_of_copies);
private:
std::map<const ExtrusionEntity*, std::vector<int>> entity_map; // to keep track of who prints what
bool something_overridden = false;
};
class ToolOrdering
{
public:
@ -39,6 +69,11 @@ public:
// and to support the wipe tower partitions above this one.
size_t wipe_tower_partitions;
coordf_t wipe_tower_layer_height;
// This holds list of extrusion that will be used for extruder wiping
WipingExtrusions wiping_extrusions;
};
ToolOrdering() {}
@ -72,7 +107,7 @@ public:
std::vector<LayerTools>::const_iterator begin() const { return m_layer_tools.begin(); }
std::vector<LayerTools>::const_iterator end() const { return m_layer_tools.end(); }
bool empty() const { return m_layer_tools.empty(); }
const std::vector<LayerTools>& layer_tools() const { return m_layer_tools; }
std::vector<LayerTools>& layer_tools() { return m_layer_tools; }
bool has_wipe_tower() const { return ! m_layer_tools.empty() && m_first_printing_extruder != (unsigned int)-1 && m_layer_tools.front().wipe_tower_partitions > 0; }
private: