Merge branch 'main' into bugfox/fov

This commit is contained in:
SoftFever 2025-02-19 19:15:41 +08:00 committed by GitHub
commit a6e53707ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 68 additions and 38 deletions

View file

@ -4415,33 +4415,43 @@ void GCodeProcessor::run_post_process()
} }
} }
} }
} } else if (line == reserved_tag(ETags::Estimated_Printing_Time_Placeholder)) {
else if (line == reserved_tag(ETags::Estimated_Printing_Time_Placeholder)) {
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) { for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
const TimeMachine& machine = m_time_processor.machines[i]; const TimeMachine& machine = m_time_processor.machines[i];
PrintEstimatedStatistics::ETimeMode mode = static_cast<PrintEstimatedStatistics::ETimeMode>(i); PrintEstimatedStatistics::ETimeMode mode = static_cast<PrintEstimatedStatistics::ETimeMode>(i);
if (mode == PrintEstimatedStatistics::ETimeMode::Normal || machine.enabled) { if (mode == PrintEstimatedStatistics::ETimeMode::Normal || machine.enabled) {
char buf[128]; char buf[128];
sprintf(buf, "; estimated printing time (%s mode) = %s\n", if (!s_IsBBLPrinter)
(mode == PrintEstimatedStatistics::ETimeMode::Normal) ? "normal" : "silent", // Orca: compatibility with klipper_estimator
get_time_dhms(machine.time).c_str()); sprintf(buf, "; estimated printing time (%s mode) = %s\n",
(mode == PrintEstimatedStatistics::ETimeMode::Normal) ? "normal" : "silent",
get_time_dhms(machine.time).c_str());
else {
sprintf(buf, "; model printing time: %s; total estimated time: %s\n",
get_time_dhms(machine.time - machine.prepare_time).c_str(), get_time_dhms(machine.time).c_str());
}
export_lines.append_line(buf); export_lines.append_line(buf);
processed = true;
} }
} }
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) { for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
const TimeMachine& machine = m_time_processor.machines[i]; const TimeMachine& machine = m_time_processor.machines[i];
PrintEstimatedStatistics::ETimeMode mode = static_cast<PrintEstimatedStatistics::ETimeMode>(i); PrintEstimatedStatistics::ETimeMode mode = static_cast<PrintEstimatedStatistics::ETimeMode>(i);
if (mode == PrintEstimatedStatistics::ETimeMode::Normal || machine.enabled) { if (mode == PrintEstimatedStatistics::ETimeMode::Normal || machine.enabled) {
char buf[128]; char buf[128];
sprintf(buf, "; estimated first layer printing time (%s mode) = %s\n", sprintf(buf, "; estimated first layer printing time (%s mode) = %s\n",
(mode == PrintEstimatedStatistics::ETimeMode::Normal) ? "normal" : "silent", (mode == PrintEstimatedStatistics::ETimeMode::Normal) ? "normal" : "silent",
get_time_dhms(machine.prepare_time).c_str()); get_time_dhms(machine.prepare_time).c_str());
export_lines.append_line(buf); export_lines.append_line(buf);
processed = true; processed = true;
} }
} }
} }
// Orca: write total layer number, this is used by Bambu printers only as of now
else if (line == reserved_tag(ETags::Total_Layer_Number_Placeholder)) {
char buf[128];
sprintf(buf, "; total layer number: %u\n", m_layer_id);
export_lines.append_line(buf);
}
} }
return processed; return processed;

View file

@ -380,7 +380,7 @@ class Print;
EMoveType move_type{ EMoveType::Noop }; EMoveType move_type{ EMoveType::Noop };
ExtrusionRole role{ erNone }; ExtrusionRole role{ erNone };
unsigned int g1_line_id{ 0 }; unsigned int g1_line_id{ 0 };
unsigned int remaining_internal_g1_lines; unsigned int remaining_internal_g1_lines{ 0 };
unsigned int layer_id{ 0 }; unsigned int layer_id{ 0 };
float distance{ 0.0f }; // mm float distance{ 0.0f }; // mm
float acceleration{ 0.0f }; // mm/s^2 float acceleration{ 0.0f }; // mm/s^2
@ -429,7 +429,7 @@ class Print;
struct G1LinesCacheItem struct G1LinesCacheItem
{ {
unsigned int id; unsigned int id;
unsigned int remaining_internal_g1_lines; unsigned int remaining_internal_g1_lines{ 0 };
float elapsed_time; float elapsed_time;
}; };

View file

@ -14,6 +14,7 @@
namespace Slic3r namespace Slic3r
{ {
static const double wipe_tower_wall_infill_overlap = 0.0;
inline float align_round(float value, float base) inline float align_round(float value, float base)
{ {
@ -118,7 +119,7 @@ public:
WipeTowerWriter& set_initial_tool(size_t tool) { m_current_tool = tool; return *this; } WipeTowerWriter& set_initial_tool(size_t tool) { m_current_tool = tool; return *this; }
WipeTowerWriter& set_z(float z) WipeTowerWriter& set_z(float z)
{ m_current_z = z; return *this; } { m_current_z = z; return *this; }
WipeTowerWriter& set_extrusion_flow(float flow) WipeTowerWriter& set_extrusion_flow(float flow)
@ -237,7 +238,7 @@ public:
WipeTowerWriter& travel(float x, float y, float f = 0.f) WipeTowerWriter& travel(float x, float y, float f = 0.f)
{ return extrude_explicit(x, y, 0.f, f); } { return extrude_explicit(x, y, 0.f, f); }
WipeTowerWriter& travel(const Vec2f &dest, float f = 0.f) WipeTowerWriter& travel(const Vec2f &dest, float f = 0.f)
{ return extrude_explicit(dest.x(), dest.y(), 0.f, f); } { return extrude_explicit(dest.x(), dest.y(), 0.f, f); }
// Extrude a line from current position to x, y with the extrusion amount given by m_extrusion_flow. // Extrude a line from current position to x, y with the extrusion amount given by m_extrusion_flow.
@ -248,7 +249,7 @@ public:
return extrude_explicit(x, y, std::sqrt(dx*dx+dy*dy) * m_extrusion_flow, f, true); return extrude_explicit(x, y, std::sqrt(dx*dx+dy*dy) * m_extrusion_flow, f, true);
} }
WipeTowerWriter& extrude(const Vec2f &dest, const float f = 0.f) WipeTowerWriter& extrude(const Vec2f &dest, const float f = 0.f)
{ return extrude(dest.x(), dest.y(), f); } { return extrude(dest.x(), dest.y(), f); }
WipeTowerWriter& rectangle(const Vec2f& ld,float width,float height,const float f = 0.f) WipeTowerWriter& rectangle(const Vec2f& ld,float width,float height,const float f = 0.f)
@ -299,7 +300,7 @@ public:
do { do {
++i; ++i;
if (i == 4) i = 0; if (i == 4) i = 0;
if (need_change_flow) { if (need_change_flow) {
if (i == 1) { if (i == 1) {
// using bridge flow in bridge area, and add notes for gcode-check when flow changed // using bridge flow in bridge area, and add notes for gcode-check when flow changed
set_extrusion_flow(wipe_tower->extrusion_flow(0.2)); set_extrusion_flow(wipe_tower->extrusion_flow(0.2));
@ -358,7 +359,7 @@ public:
// Elevate the extruder head above the current print_z position. // Elevate the extruder head above the current print_z position.
WipeTowerWriter& z_hop(float hop, float f = 0.f) WipeTowerWriter& z_hop(float hop, float f = 0.f)
{ {
m_gcode += std::string("G1") + set_format_Z(m_current_z + hop); m_gcode += std::string("G1") + set_format_Z(m_current_z + hop);
if (f != 0 && f != m_current_feedrate) if (f != 0 && f != m_current_feedrate)
m_gcode += set_format_F(f); m_gcode += set_format_F(f);
@ -367,7 +368,7 @@ public:
} }
// Lower the extruder head back to the current print_z position. // Lower the extruder head back to the current print_z position.
WipeTowerWriter& z_hop_reset(float f = 0.f) WipeTowerWriter& z_hop_reset(float f = 0.f)
{ return z_hop(0, f); } { return z_hop(0, f); }
// Move to x1, +y_increment, // Move to x1, +y_increment,
@ -455,14 +456,14 @@ public:
} }
WipeTowerWriter& flush_planner_queue() WipeTowerWriter& flush_planner_queue()
{ {
m_gcode += "G4 S0\n"; m_gcode += "G4 S0\n";
return *this; return *this;
} }
// Reset internal extruder counter. // Reset internal extruder counter.
WipeTowerWriter& reset_extruder() WipeTowerWriter& reset_extruder()
{ {
m_gcode += "G92 E0\n"; m_gcode += "G92 E0\n";
return *this; return *this;
} }
@ -725,7 +726,7 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config)
// Returns gcode to prime the nozzles at the front edge of the print bed. // Returns gcode to prime the nozzles at the front edge of the print bed.
std::vector<WipeTower::ToolChangeResult> WipeTower::prime( std::vector<WipeTower::ToolChangeResult> WipeTower::prime(
// print_z of the first layer. // print_z of the first layer.
float initial_layer_print_height, float initial_layer_print_height,
// Extruder indices, in the order to be primed. The last extruder will later print the wipe tower brim, print brim and the object. // Extruder indices, in the order to be primed. The last extruder will later print the wipe tower brim, print brim and the object.
const std::vector<unsigned int> &tools, const std::vector<unsigned int> &tools,
// If true, the last priming are will be the same as the other priming areas, and the rest of the wipe will be performed inside the wipe tower. // If true, the last priming are will be the same as the other priming areas, and the rest of the wipe will be performed inside the wipe tower.
@ -742,7 +743,7 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool, bool extrude_per
float wipe_depth = 0.f; float wipe_depth = 0.f;
float wipe_length = 0.f; float wipe_length = 0.f;
float purge_volume = 0.f; float purge_volume = 0.f;
// Finds this toolchange info // Finds this toolchange info
if (tool != (unsigned int)(-1)) if (tool != (unsigned int)(-1))
{ {
@ -802,12 +803,30 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool, bool extrude_per
box_coordinates wt_box(Vec2f(0.f, (m_current_shape == SHAPE_REVERSED) ? m_layer_info->toolchanges_depth() - m_layer_info->depth : 0.f), box_coordinates wt_box(Vec2f(0.f, (m_current_shape == SHAPE_REVERSED) ? m_layer_info->toolchanges_depth() - m_layer_info->depth : 0.f),
m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); m_wipe_tower_width, m_layer_info->depth + m_perimeter_width);
// align the perimeter // align the perimeter
Vec2f pos = initial_position;
switch (m_cur_layer_id % 4){
case 0:
pos = wt_box.ld;
break;
case 1:
pos = wt_box.rd;
break;
case 2:
pos = wt_box.ru;
break;
case 3:
pos = wt_box.lu;
break;
default: break;
}
writer.set_initial_position(pos, m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation);
wt_box = align_perimeter(wt_box); wt_box = align_perimeter(wt_box);
writer.rectangle(wt_box); writer.rectangle(wt_box);
writer.travel(initial_position);
} }
if (first_toolchange_to_nonsoluble) { {
writer.travel(Vec2f(0, 0)); writer.travel(Vec2f(0, 0));
writer.travel(initial_position); writer.travel(initial_position);
} }
@ -849,7 +868,7 @@ void WipeTower::toolchange_Unload(
#if 0 #if 0
float xl = cleaning_box.ld.x() + 1.f * m_perimeter_width; float xl = cleaning_box.ld.x() + 1.f * m_perimeter_width;
float xr = cleaning_box.rd.x() - 1.f * m_perimeter_width; float xr = cleaning_box.rd.x() - 1.f * m_perimeter_width;
const float line_width = m_perimeter_width * m_filpar[m_current_tool].ramming_line_width_multiplicator; // desired ramming line thickness const float line_width = m_perimeter_width * m_filpar[m_current_tool].ramming_line_width_multiplicator; // desired ramming line thickness
const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm
@ -1108,9 +1127,9 @@ void WipeTower::toolchange_Wipe(
} }
if (m_left_to_right) if (m_left_to_right)
writer.extrude(xr + 0.25f * m_perimeter_width, writer.y(), wipe_speed); writer.extrude(xr + wipe_tower_wall_infill_overlap * m_perimeter_width, writer.y(), wipe_speed);
else else
writer.extrude(xl - 0.25f * m_perimeter_width, writer.y(), wipe_speed); writer.extrude(xl - wipe_tower_wall_infill_overlap * m_perimeter_width, writer.y(), wipe_speed);
// BBS: recover the flow in non-bridging area // BBS: recover the flow in non-bridging area
if (need_change_flow) { if (need_change_flow) {
@ -1139,7 +1158,7 @@ void WipeTower::toolchange_Wipe(
//writer.add_wipe_point(writer.x(), writer.y()) //writer.add_wipe_point(writer.x(), writer.y())
// .add_wipe_point(writer.x(), writer.y() - dy) // .add_wipe_point(writer.x(), writer.y() - dy)
// .add_wipe_point(! m_left_to_right ? m_wipe_tower_width : 0.f, writer.y() - dy); // .add_wipe_point(! m_left_to_right ? m_wipe_tower_width : 0.f, writer.y() - dy);
// BBS: modify the wipe_path after toolchange // BBS: modify the wipe_path after toolchange
writer.add_wipe_point(writer.x(), writer.y()) writer.add_wipe_point(writer.x(), writer.y())
.add_wipe_point(! m_left_to_right ? m_wipe_tower_width : 0.f, writer.y()); .add_wipe_point(! m_left_to_right ? m_wipe_tower_width : 0.f, writer.y());
@ -1473,7 +1492,7 @@ void WipeTower::plan_tower()
m_wipe_tower_depth = 0.f; m_wipe_tower_depth = 0.f;
for (auto& layer : m_plan) for (auto& layer : m_plan)
layer.depth = 0.f; layer.depth = 0.f;
float max_depth_for_all = 0; float max_depth_for_all = 0;
for (int layer_index = int(m_plan.size()) - 1; layer_index >= 0; --layer_index) for (int layer_index = int(m_plan.size()) - 1; layer_index >= 0; --layer_index)
{ {
@ -1482,7 +1501,7 @@ void WipeTower::plan_tower()
this_layer_depth = min_wipe_tower_depth; this_layer_depth = min_wipe_tower_depth;
m_plan[layer_index].depth = this_layer_depth; m_plan[layer_index].depth = this_layer_depth;
if (this_layer_depth > m_wipe_tower_depth - m_perimeter_width) if (this_layer_depth > m_wipe_tower_depth - m_perimeter_width)
m_wipe_tower_depth = this_layer_depth + m_perimeter_width; m_wipe_tower_depth = this_layer_depth + m_perimeter_width;
@ -1492,7 +1511,7 @@ void WipeTower::plan_tower()
m_plan[i].depth = this_layer_depth; m_plan[i].depth = this_layer_depth;
} }
if (m_enable_timelapse_print && layer_index == 0) if (m_enable_timelapse_print && layer_index == 0)
max_depth_for_all = m_plan[0].depth; max_depth_for_all = m_plan[0].depth;
} }
@ -1600,10 +1619,11 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
used = 0.f; used = 0.f;
m_old_temperature = -1; // reset last temperature written in the gcode m_old_temperature = -1; // reset last temperature written in the gcode
int index = 0;
std::vector<WipeTower::ToolChangeResult> layer_result; std::vector<WipeTower::ToolChangeResult> layer_result;
for (auto layer : m_plan) for (auto layer : m_plan)
{ {
m_cur_layer_id = index++;
set_layer(layer.z, layer.height, 0, false/*layer.z == m_plan.front().z*/, layer.z == m_plan.back().z); set_layer(layer.z, layer.height, 0, false/*layer.z == m_plan.front().z*/, layer.z == m_plan.back().z);
// BBS // BBS
//m_internal_rotation += 180.f; //m_internal_rotation += 180.f;
@ -1627,14 +1647,14 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
// if there is no toolchange switching to non-soluble, finish layer // if there is no toolchange switching to non-soluble, finish layer
// will be called at the very beginning. That's the last possibility // will be called at the very beginning. That's the last possibility
// where a nonsoluble tool can be. // where a nonsoluble tool can be.
if (m_enable_timelapse_print) { if (m_enable_timelapse_print) {
timelapse_wall = only_generate_out_wall(); timelapse_wall = only_generate_out_wall();
} }
finish_layer_tcr = finish_layer(m_enable_timelapse_print ? false : true, layer.extruder_fill); finish_layer_tcr = finish_layer(m_enable_timelapse_print ? false : true, layer.extruder_fill);
} }
for (int i=0; i<int(layer.tool_changes.size()); ++i) { for (int i=0; i<int(layer.tool_changes.size()); ++i) {
if (i == 0 && m_enable_timelapse_print) { if (i == 0 && m_enable_timelapse_print) {
timelapse_wall = only_generate_out_wall(); timelapse_wall = only_generate_out_wall();
} }

View file

@ -304,7 +304,7 @@ private:
float m_travel_speed = 0.f; float m_travel_speed = 0.f;
float m_first_layer_speed = 0.f; float m_first_layer_speed = 0.f;
size_t m_first_layer_idx = size_t(-1); size_t m_first_layer_idx = size_t(-1);
size_t m_cur_layer_id;
// G-code generator parameters. // G-code generator parameters.
float m_cooling_tube_retraction = 0.f; float m_cooling_tube_retraction = 0.f;
float m_cooling_tube_length = 0.f; float m_cooling_tube_length = 0.f;