mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Refactored ToolOrdering to a class,
layers with print_z closer than EPSILON are merged and printed together.
This commit is contained in:
parent
aad9f61bad
commit
ca590cb559
3 changed files with 200 additions and 163 deletions
|
@ -7,49 +7,70 @@
|
|||
#include "Print.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace ToolOrdering {
|
||||
|
||||
struct LayerTools
|
||||
class ToolOrdering
|
||||
{
|
||||
LayerTools(const coordf_t z) :
|
||||
print_z(z),
|
||||
has_object(false),
|
||||
has_support(false),
|
||||
has_wipe_tower(false),
|
||||
wipe_tower_partitions(0) {}
|
||||
public:
|
||||
struct LayerTools
|
||||
{
|
||||
LayerTools(const coordf_t z) :
|
||||
print_z(z),
|
||||
has_object(false),
|
||||
has_support(false),
|
||||
has_wipe_tower(false),
|
||||
wipe_tower_partitions(0) {}
|
||||
|
||||
bool operator< (const LayerTools &rhs) const { return print_z < rhs.print_z; }
|
||||
bool operator==(const LayerTools &rhs) const { return print_z == rhs.print_z; }
|
||||
bool operator< (const LayerTools &rhs) const { return print_z < rhs.print_z; }
|
||||
bool operator==(const LayerTools &rhs) const { return print_z == rhs.print_z; }
|
||||
|
||||
coordf_t print_z;
|
||||
bool has_object;
|
||||
bool has_support;
|
||||
// Zero based extruder IDs, ordered to minimize tool switches.
|
||||
std::vector<unsigned int> extruders;
|
||||
// Will there be anything extruded on this layer for the wipe tower?
|
||||
// Due to the support layers possibly interleaving the object layers,
|
||||
// wipe tower will be disabled for some support only layers.
|
||||
bool has_wipe_tower;
|
||||
// Number of wipe tower partitions to support the required number of tool switches
|
||||
// and to support the wipe tower partitions above this one.
|
||||
size_t wipe_tower_partitions;
|
||||
coordf_t print_z;
|
||||
bool has_object;
|
||||
bool has_support;
|
||||
// Zero based extruder IDs, ordered to minimize tool switches.
|
||||
std::vector<unsigned int> extruders;
|
||||
// Will there be anything extruded on this layer for the wipe tower?
|
||||
// Due to the support layers possibly interleaving the object layers,
|
||||
// wipe tower will be disabled for some support only layers.
|
||||
bool has_wipe_tower;
|
||||
// Number of wipe tower partitions to support the required number of tool switches
|
||||
// and to support the wipe tower partitions above this one.
|
||||
size_t wipe_tower_partitions;
|
||||
};
|
||||
|
||||
ToolOrdering() {}
|
||||
|
||||
// For the use case when each object is printed separately
|
||||
// (print.config.complete_objects is true).
|
||||
ToolOrdering(const PrintObject &object, unsigned int first_extruder = (unsigned int)-1);
|
||||
|
||||
// For the use case when all objects are printed at once.
|
||||
// (print.config.complete_objects is false).
|
||||
ToolOrdering(const Print &print, unsigned int first_extruder = (unsigned int)-1);
|
||||
|
||||
// Get the first extruder printing the layer_tools, returns -1 if there is no layer printed.
|
||||
unsigned int first_extruder() const;
|
||||
|
||||
// Get the first extruder printing the layer_tools, returns -1 if there is no layer printed.
|
||||
unsigned int last_extruder() const;
|
||||
|
||||
// Find LayerTools with the closest print_z.
|
||||
LayerTools& tools_for_layer(coordf_t print_z);
|
||||
const LayerTools& tools_for_layer(coordf_t print_z) const
|
||||
{ return *const_cast<const LayerTools*>(&const_cast<const ToolOrdering*>(this)->tools_for_layer(print_z)); }
|
||||
|
||||
const LayerTools& front() const { return m_layer_tools.front(); }
|
||||
const LayerTools& back() const { return m_layer_tools.back(); }
|
||||
bool empty() const { return m_layer_tools.empty(); }
|
||||
|
||||
private:
|
||||
void initialize_layers(std::vector<coordf_t> &zs);
|
||||
void collect_extruders(const PrintObject &object);
|
||||
void reorder_extruders(unsigned int last_extruder_id);
|
||||
void fill_wipe_tower_partitions();
|
||||
|
||||
std::vector<LayerTools> m_layer_tools;
|
||||
};
|
||||
|
||||
// For the use case when each object is printed separately
|
||||
// (print.config.complete_objects is true).
|
||||
extern std::vector<LayerTools> tool_ordering(const PrintObject &object, unsigned int first_extruder = (unsigned int)-1);
|
||||
|
||||
// For the use case when all objects are printed at once.
|
||||
// (print.config.complete_objects is false).
|
||||
extern std::vector<LayerTools> tool_ordering(const Print &print, unsigned int first_extruder = (unsigned int)-1);
|
||||
|
||||
// Get the first extruder printing the layer_tools, returns -1 if there is no layer printed.
|
||||
extern unsigned int first_extruder(const std::vector<LayerTools> &layer_tools);
|
||||
|
||||
// Get the first extruder printing the layer_tools, returns -1 if there is no layer printed.
|
||||
extern unsigned int last_extruder(const std::vector<LayerTools> &layer_tools);
|
||||
|
||||
} // namespace ToolOrdering
|
||||
} // namespace SLic3r
|
||||
|
||||
#endif /* slic3r_ToolOrdering_hpp_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue