mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-07-27 03:44:53 +03:00
Merged with dev
This commit is contained in:
@@ -154,6 +154,12 @@ public:
|
||||
// the wipe tower has been completely covered by the tool change extrusions,
|
||||
// or the rest of the tower has been filled by a sparse infill with the finish_layer() method.
|
||||
virtual bool layer_finished() const = 0;
|
||||
|
||||
// Returns used filament length per extruder:
|
||||
virtual std::vector<float> get_used_filament() const = 0;
|
||||
|
||||
// Returns total number of toolchanges:
|
||||
virtual int get_number_of_toolchanges() const = 0;
|
||||
};
|
||||
|
||||
}; // namespace Slic3r
|
||||
|
||||
@@ -111,9 +111,10 @@ public:
|
||||
const WipeTower::xy start_pos_rotated() const { return m_start_pos; }
|
||||
const WipeTower::xy pos_rotated() const { return WipeTower::xy(m_current_pos, 0.f, m_y_shift).rotate(m_wipe_tower_width, m_wipe_tower_depth, m_internal_angle); }
|
||||
float elapsed_time() const { return m_elapsed_time; }
|
||||
float get_and_reset_used_filament_length() { float temp = m_used_filament_length; m_used_filament_length = 0.f; return temp; }
|
||||
|
||||
// Extrude with an explicitely provided amount of extrusion.
|
||||
Writer& extrude_explicit(float x, float y, float e, float f = 0.f)
|
||||
Writer& extrude_explicit(float x, float y, float e, float f = 0.f, bool record_length = false)
|
||||
{
|
||||
if (x == m_current_pos.x && y == m_current_pos.y && e == 0.f && (f == 0.f || f == m_current_feedrate))
|
||||
// Neither extrusion nor a travel move.
|
||||
@@ -122,6 +123,8 @@ public:
|
||||
float dx = x - m_current_pos.x;
|
||||
float dy = y - m_current_pos.y;
|
||||
double len = sqrt(dx*dx+dy*dy);
|
||||
if (record_length)
|
||||
m_used_filament_length += e;
|
||||
|
||||
|
||||
// Now do the "internal rotation" with respect to the wipe tower center
|
||||
@@ -162,8 +165,8 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Writer& extrude_explicit(const WipeTower::xy &dest, float e, float f = 0.f)
|
||||
{ return extrude_explicit(dest.x, dest.y, e, f); }
|
||||
Writer& extrude_explicit(const WipeTower::xy &dest, float e, float f = 0.f, bool record_length = false)
|
||||
{ return extrude_explicit(dest.x, dest.y, e, f, record_length); }
|
||||
|
||||
// Travel to a new XY position. f=0 means use the current value.
|
||||
Writer& travel(float x, float y, float f = 0.f)
|
||||
@@ -177,7 +180,7 @@ public:
|
||||
{
|
||||
float dx = x - m_current_pos.x;
|
||||
float dy = y - m_current_pos.y;
|
||||
return extrude_explicit(x, y, sqrt(dx*dx+dy*dy) * m_extrusion_flow, f);
|
||||
return extrude_explicit(x, y, sqrt(dx*dx+dy*dy) * m_extrusion_flow, f, true);
|
||||
}
|
||||
|
||||
Writer& extrude(const WipeTower::xy &dest, const float f = 0.f)
|
||||
@@ -259,8 +262,8 @@ public:
|
||||
// extrude quickly amount e to x2 with feed f.
|
||||
Writer& ram(float x1, float x2, float dy, float e0, float e, float f)
|
||||
{
|
||||
extrude_explicit(x1, m_current_pos.y + dy, e0, f);
|
||||
extrude_explicit(x2, m_current_pos.y, e);
|
||||
extrude_explicit(x1, m_current_pos.y + dy, e0, f, true);
|
||||
extrude_explicit(x2, m_current_pos.y, e, 0.f, true);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -404,6 +407,7 @@ private:
|
||||
float m_last_fan_speed = 0.f;
|
||||
int current_temp = -1;
|
||||
const float m_default_analyzer_line_width;
|
||||
float m_used_filament_length = 0.f;
|
||||
|
||||
std::string set_format_X(float x)
|
||||
{
|
||||
@@ -525,6 +529,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
|
||||
++ m_num_tool_changes;
|
||||
}
|
||||
|
||||
m_old_temperature = -1; // If the priming is turned off in config, the temperature changing commands will not actually appear
|
||||
// in the output gcode - we should not remember emitting them (we will output them twice in the worst case)
|
||||
|
||||
// Reset the extruder current to a normal value.
|
||||
writer.set_extruder_trimpot(550)
|
||||
.feedrate(6000)
|
||||
@@ -537,6 +544,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
|
||||
// so that tool_change() will know to extrude the wipe tower brim:
|
||||
m_print_brim = true;
|
||||
|
||||
// Ask our writer about how much material was consumed:
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
ToolChangeResult result;
|
||||
result.priming = true;
|
||||
result.print_z = this->m_z_pos;
|
||||
@@ -606,10 +616,10 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
|
||||
toolchange_Load(writer, cleaning_box);
|
||||
writer.travel(writer.x(),writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road
|
||||
toolchange_Wipe(writer, cleaning_box, wipe_volume); // Wipe the newly loaded filament until the end of the assigned wipe area.
|
||||
++ m_num_tool_changes;
|
||||
} else
|
||||
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, m_filpar[m_current_tool].temperature);
|
||||
|
||||
++ m_num_tool_changes;
|
||||
m_depth_traversed += wipe_area;
|
||||
|
||||
if (last_change_in_layer) {// draw perimeter line
|
||||
@@ -632,6 +642,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
|
||||
";------------------\n"
|
||||
"\n\n");
|
||||
|
||||
// Ask our writer about how much material was consumed:
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
ToolChangeResult result;
|
||||
result.priming = false;
|
||||
result.print_z = this->m_z_pos;
|
||||
@@ -683,6 +696,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(bool sideOnly, flo
|
||||
|
||||
m_print_brim = false; // Mark the brim as extruded
|
||||
|
||||
// Ask our writer about how much material was consumed:
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
ToolChangeResult result;
|
||||
result.priming = false;
|
||||
result.print_z = this->m_z_pos;
|
||||
@@ -804,8 +820,9 @@ void WipeTowerPrusaMM::toolchange_Unload(
|
||||
.load_move_x_advanced(old_x, -0.10f * total_retraction_distance, 0.3f * m_filpar[m_current_tool].unloading_speed)
|
||||
.travel(old_x, writer.y()) // in case previous move was shortened to limit feedrate*/
|
||||
.resume_preview();
|
||||
|
||||
if (new_temperature != 0 && new_temperature != m_old_temperature ) { // Set the extruder temperature, but don't wait.
|
||||
if (new_temperature != 0 && (new_temperature != m_old_temperature || m_is_first_layer) ) { // Set the extruder temperature, but don't wait.
|
||||
// If the required temperature is the same as last time, don't emit the M104 again (if user adjusted the value, it would be reset)
|
||||
// However, always change temperatures on the first layer (this is to avoid issues with priming lines turned off).
|
||||
writer.set_extruder_temp(new_temperature, false);
|
||||
m_old_temperature = new_temperature;
|
||||
}
|
||||
@@ -849,6 +866,9 @@ void WipeTowerPrusaMM::toolchange_Change(
|
||||
const unsigned int new_tool,
|
||||
material_type new_material)
|
||||
{
|
||||
// Ask the writer about how much of the old filament we consumed:
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
// Speed override for the material. Go slow for flex and soluble materials.
|
||||
int speed_override;
|
||||
switch (new_material) {
|
||||
@@ -911,7 +931,6 @@ void WipeTowerPrusaMM::toolchange_Wipe(
|
||||
const float& xl = cleaning_box.ld.x;
|
||||
const float& xr = cleaning_box.rd.x;
|
||||
|
||||
|
||||
// Variables x_to_wipe and traversed_x are here to be able to make sure it always wipes at least
|
||||
// the ordered volume, even if it means violating the box. This can later be removed and simply
|
||||
// wipe until the end of the assigned area.
|
||||
@@ -926,7 +945,6 @@ void WipeTowerPrusaMM::toolchange_Wipe(
|
||||
m_left_to_right = !m_left_to_right;
|
||||
}
|
||||
|
||||
|
||||
// now the wiping itself:
|
||||
for (int i = 0; true; ++i) {
|
||||
if (i!=0) {
|
||||
@@ -935,7 +953,7 @@ void WipeTowerPrusaMM::toolchange_Wipe(
|
||||
else if (wipe_speed < 2210.f) wipe_speed = 4200.f;
|
||||
else wipe_speed = std::min(4800.f, wipe_speed + 50.f);
|
||||
}
|
||||
|
||||
|
||||
float traversed_x = writer.x();
|
||||
if (m_left_to_right)
|
||||
writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff);
|
||||
@@ -1050,6 +1068,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer()
|
||||
|
||||
m_depth_traversed = m_wipe_tower_depth-m_perimeter_width;
|
||||
|
||||
// Ask our writer about how much material was consumed:
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
ToolChangeResult result;
|
||||
result.priming = false;
|
||||
result.print_z = this->m_z_pos;
|
||||
@@ -1166,6 +1187,8 @@ void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeRes
|
||||
|
||||
m_layer_info = m_plan.begin();
|
||||
m_current_tool = (unsigned int)(-2); // we don't know which extruder to start with - we'll set it according to the first toolchange
|
||||
for (auto& used : m_used_filament_length) // reset used filament stats
|
||||
used = 0.f;
|
||||
|
||||
std::vector<WipeTower::ToolChangeResult> layer_result;
|
||||
for (auto layer : m_plan)
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
WipeTowerPrusaMM(float x, float y, float width, float rotation_angle, float cooling_tube_retraction,
|
||||
float cooling_tube_length, float parking_pos_retraction, float extra_loading_move, float bridging,
|
||||
const std::vector<std::vector<float>>& wiping_matrix, unsigned int initial_tool) :
|
||||
m_wipe_tower_pos(x, y),
|
||||
m_wipe_tower_pos(x, y),
|
||||
m_wipe_tower_width(width),
|
||||
m_wipe_tower_rotation_angle(rotation_angle),
|
||||
m_y_shift(0.f),
|
||||
@@ -94,6 +94,8 @@ public:
|
||||
m_filpar[idx].ramming_step_multiplicator /= 100;
|
||||
while (stream >> speed)
|
||||
m_filpar[idx].ramming_speed.push_back(speed);
|
||||
|
||||
m_used_filament_length.resize(std::max(m_used_filament_length.size(), idx + 1)); // makes sure that the vector is big enough so we don't have to check later
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +174,9 @@ public:
|
||||
return ( (m_is_first_layer ? m_wipe_tower_depth - m_perimeter_width : m_layer_info->depth) - WT_EPSILON < m_depth_traversed);
|
||||
}
|
||||
|
||||
virtual std::vector<float> get_used_filament() const override { return m_used_filament_length; }
|
||||
virtual int get_number_of_toolchanges() const override { return m_num_tool_changes; }
|
||||
|
||||
|
||||
private:
|
||||
WipeTowerPrusaMM();
|
||||
@@ -331,6 +336,9 @@ private:
|
||||
std::vector<WipeTowerInfo> m_plan; // Stores information about all layers and toolchanges for the future wipe tower (filled by plan_toolchange(...))
|
||||
std::vector<WipeTowerInfo>::iterator m_layer_info = m_plan.end();
|
||||
|
||||
// Stores information about used filament length per extruder:
|
||||
std::vector<float> m_used_filament_length;
|
||||
|
||||
|
||||
// Returns gcode for wipe tower brim
|
||||
// sideOnly -- set to false -- experimental, draw brim on sides of wipe tower
|
||||
|
||||
Reference in New Issue
Block a user