|
|
|
@ -9,17 +9,6 @@
|
|
|
|
|
#include "BoundingBox.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Experimental "Peter's wipe tower" feature was partially implemented, inspired by
|
|
|
|
|
// PJR's idea of alternating two perpendicular wiping directions on a square tower.
|
|
|
|
|
// It is probably never going to be finished, there are multiple remaining issues
|
|
|
|
|
// and there is probably no need to go down this way. m_peters_wipe_tower variable
|
|
|
|
|
// turns this on, maybe it should just be removed. Anyway, the issues are
|
|
|
|
|
// - layer's are not exactly square
|
|
|
|
|
// - variable width for higher levels
|
|
|
|
|
// - make sure it is not too sparse (apply max_bridge_distance and make last wipe longer)
|
|
|
|
|
// - enable enhanced first layer adhesion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Slic3r
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -122,8 +111,10 @@ public:
|
|
|
|
|
|
|
|
|
|
WipeTowerWriter& feedrate(float f)
|
|
|
|
|
{
|
|
|
|
|
if (f != m_current_feedrate)
|
|
|
|
|
if (f != m_current_feedrate) {
|
|
|
|
|
m_gcode += "G1" + set_format_F(f) + "\n";
|
|
|
|
|
m_current_feedrate = f;
|
|
|
|
|
}
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -216,7 +207,7 @@ public:
|
|
|
|
|
|
|
|
|
|
WipeTowerWriter& extrude(const Vec2f &dest, const float f = 0.f)
|
|
|
|
|
{ return extrude(dest.x(), dest.y(), f); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WipeTowerWriter& rectangle(const Vec2f& ld,float width,float height,const float f = 0.f)
|
|
|
|
|
{
|
|
|
|
|
Vec2f corners[4];
|
|
|
|
@ -242,6 +233,14 @@ public:
|
|
|
|
|
return (*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WipeTowerWriter& rectangle(const WipeTower::box_coordinates& box, const float f = 0.f)
|
|
|
|
|
{
|
|
|
|
|
rectangle(Vec2f(box.ld.x(), box.ld.y()),
|
|
|
|
|
box.ru.x() - box.lu.x(),
|
|
|
|
|
box.ru.y() - box.rd.y(), f);
|
|
|
|
|
return (*this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WipeTowerWriter& load(float e, float f = 0.f)
|
|
|
|
|
{
|
|
|
|
|
if (e == 0.f && (f == 0.f || f == m_current_feedrate))
|
|
|
|
@ -523,13 +522,21 @@ WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<fl
|
|
|
|
|
m_wipe_tower_brim_width(float(config.wipe_tower_brim_width)),
|
|
|
|
|
m_y_shift(0.f),
|
|
|
|
|
m_z_pos(0.f),
|
|
|
|
|
m_is_first_layer(false),
|
|
|
|
|
m_bridging(float(config.wipe_tower_bridging)),
|
|
|
|
|
m_no_sparse_layers(config.wipe_tower_no_sparse_layers),
|
|
|
|
|
m_gcode_flavor(config.gcode_flavor),
|
|
|
|
|
m_travel_speed(config.travel_speed),
|
|
|
|
|
m_current_tool(initial_tool),
|
|
|
|
|
wipe_volumes(wiping_matrix)
|
|
|
|
|
{
|
|
|
|
|
// Read absolute value of first layer speed, if given as percentage,
|
|
|
|
|
// it is taken over following default. Speeds from config are not
|
|
|
|
|
// easily accessible here.
|
|
|
|
|
const float default_speed = 60.f;
|
|
|
|
|
m_first_layer_speed = config.get_abs_value("first_layer_speed", default_speed);
|
|
|
|
|
if (m_first_layer_speed == 0.f) // just to make sure autospeed doesn't break it.
|
|
|
|
|
m_first_layer_speed = default_speed / 2.f;
|
|
|
|
|
|
|
|
|
|
// If this is a single extruder MM printer, we will use all the SE-specific config values.
|
|
|
|
|
// Otherwise, the defaults will be used to turn off the SE stuff.
|
|
|
|
|
if (m_semm) {
|
|
|
|
@ -556,6 +563,7 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config)
|
|
|
|
|
m_filpar.push_back(FilamentParameters());
|
|
|
|
|
|
|
|
|
|
m_filpar[idx].material = config.filament_type.get_at(idx);
|
|
|
|
|
m_filpar[idx].is_soluble = config.filament_soluble.get_at(idx);
|
|
|
|
|
m_filpar[idx].temperature = config.temperature.get_at(idx);
|
|
|
|
|
m_filpar[idx].first_layer_temperature = config.first_layer_temperature.get_at(idx);
|
|
|
|
|
|
|
|
|
@ -680,7 +688,7 @@ std::vector<WipeTower::ToolChangeResult> WipeTower::prime(
|
|
|
|
|
if (m_set_extruder_trimpot)
|
|
|
|
|
writer.set_extruder_trimpot(550);
|
|
|
|
|
writer.speed_override_restore()
|
|
|
|
|
.feedrate(6000)
|
|
|
|
|
.feedrate(m_travel_speed * 60.f)
|
|
|
|
|
.flush_planner_queue()
|
|
|
|
|
.reset_extruder()
|
|
|
|
|
.append("; CP PRIMING END\n"
|
|
|
|
@ -694,21 +702,14 @@ std::vector<WipeTower::ToolChangeResult> WipeTower::prime(
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
// so that tool_change() will know to extrude the wipe tower brim:
|
|
|
|
|
m_print_brim = true;
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
|
|
|
|
{
|
|
|
|
|
if ( m_print_brim )
|
|
|
|
|
return toolchange_Brim();
|
|
|
|
|
|
|
|
|
|
size_t old_tool = m_current_tool;
|
|
|
|
|
|
|
|
|
|
float wipe_area = 0.f;
|
|
|
|
|
bool last_change_in_layer = false;
|
|
|
|
|
float wipe_area = 0.f;
|
|
|
|
|
float wipe_volume = 0.f;
|
|
|
|
|
|
|
|
|
|
// Finds this toolchange info
|
|
|
|
@ -716,9 +717,7 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
|
|
|
|
{
|
|
|
|
|
for (const auto &b : m_layer_info->tool_changes)
|
|
|
|
|
if ( b.new_tool == tool ) {
|
|
|
|
|
wipe_volume = b.wipe_volume;
|
|
|
|
|
if (tool == m_layer_info->tool_changes.back().new_tool)
|
|
|
|
|
last_change_in_layer = true;
|
|
|
|
|
wipe_volume = b.wipe_volume;
|
|
|
|
|
wipe_area = b.required_depth * m_layer_info->extra_spacing;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -727,17 +726,17 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
|
|
|
|
// Otherwise we are going to Unload only. And m_layer_info would be invalid.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
box_coordinates cleaning_box(
|
|
|
|
|
box_coordinates cleaning_box(
|
|
|
|
|
Vec2f(m_perimeter_width / 2.f, m_perimeter_width / 2.f),
|
|
|
|
|
m_wipe_tower_width - m_perimeter_width,
|
|
|
|
|
(tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5f*m_perimeter_width
|
|
|
|
|
(tool != (unsigned int)(-1) ? wipe_area+m_depth_traversed-0.5f*m_perimeter_width
|
|
|
|
|
: m_wipe_tower_depth-m_perimeter_width));
|
|
|
|
|
|
|
|
|
|
WipeTowerWriter writer(m_layer_height, m_perimeter_width, m_gcode_flavor, m_filpar);
|
|
|
|
|
writer.set_extrusion_flow(m_extrusion_flow)
|
|
|
|
|
.set_z(m_z_pos)
|
|
|
|
|
.set_initial_tool(m_current_tool)
|
|
|
|
|
.set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f))
|
|
|
|
|
.set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f))
|
|
|
|
|
.append(";--------------------\n"
|
|
|
|
|
"; CP TOOLCHANGE START\n")
|
|
|
|
|
.comment_with_value(" toolchange #", m_num_tool_changes + 1); // the number is zero-based
|
|
|
|
@ -759,7 +758,7 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
|
|
|
|
// Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
|
|
|
|
|
if (tool != (unsigned int)-1){ // This is not the last change.
|
|
|
|
|
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material,
|
|
|
|
|
m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature);
|
|
|
|
|
is_first_layer() ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature);
|
|
|
|
|
toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials.
|
|
|
|
|
toolchange_Load(writer, cleaning_box);
|
|
|
|
|
writer.travel(writer.x(), writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road
|
|
|
|
@ -770,24 +769,10 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
|
|
|
|
|
|
|
|
|
m_depth_traversed += wipe_area;
|
|
|
|
|
|
|
|
|
|
if (last_change_in_layer) {// draw perimeter line
|
|
|
|
|
writer.set_y_shift(m_y_shift);
|
|
|
|
|
if (m_peters_wipe_tower)
|
|
|
|
|
writer.rectangle(Vec2f::Zero(), m_layer_info->depth + 3*m_perimeter_width, m_wipe_tower_depth);
|
|
|
|
|
else {
|
|
|
|
|
writer.rectangle(Vec2f::Zero(), m_wipe_tower_width, m_layer_info->depth + m_perimeter_width);
|
|
|
|
|
if (layer_finished()) { // no finish_layer will be called, we must wipe the nozzle
|
|
|
|
|
writer.add_wipe_point(writer.x(), writer.y())
|
|
|
|
|
.add_wipe_point(writer.x()> m_wipe_tower_width / 2.f ? 0.f : m_wipe_tower_width, writer.y());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_set_extruder_trimpot)
|
|
|
|
|
writer.set_extruder_trimpot(550); // Reset the extruder current to a normal value.
|
|
|
|
|
writer.speed_override_restore();
|
|
|
|
|
writer.feedrate(6000)
|
|
|
|
|
writer.feedrate(m_travel_speed * 60.f)
|
|
|
|
|
.flush_planner_queue()
|
|
|
|
|
.reset_extruder()
|
|
|
|
|
.append("; CP TOOLCHANGE END\n"
|
|
|
|
@ -801,66 +786,6 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
|
|
|
|
return construct_tcr(writer, false, old_tool);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WipeTower::ToolChangeResult WipeTower::toolchange_Brim(bool sideOnly, float y_offset)
|
|
|
|
|
{
|
|
|
|
|
size_t old_tool = m_current_tool;
|
|
|
|
|
|
|
|
|
|
const box_coordinates wipeTower_box(
|
|
|
|
|
Vec2f::Zero(),
|
|
|
|
|
m_wipe_tower_width,
|
|
|
|
|
m_wipe_tower_depth);
|
|
|
|
|
|
|
|
|
|
WipeTowerWriter writer(m_layer_height, m_perimeter_width, m_gcode_flavor, m_filpar);
|
|
|
|
|
writer.set_extrusion_flow(m_extrusion_flow * 1.1f)
|
|
|
|
|
.set_z(m_z_pos) // Let the writer know the current Z position as a base for Z-hop.
|
|
|
|
|
.set_initial_tool(m_current_tool)
|
|
|
|
|
.append(";-------------------------------------\n"
|
|
|
|
|
"; CP WIPE TOWER FIRST LAYER BRIM START\n");
|
|
|
|
|
|
|
|
|
|
Vec2f initial_position = wipeTower_box.lu - Vec2f(m_wipe_tower_brim_width + 2*m_perimeter_width, 0);
|
|
|
|
|
writer.set_initial_position(initial_position, m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation);
|
|
|
|
|
|
|
|
|
|
// Prime the extruder left of the wipe tower.
|
|
|
|
|
writer.extrude_explicit(wipeTower_box.ld - Vec2f(m_wipe_tower_brim_width + 2*m_perimeter_width, 0),
|
|
|
|
|
1.5f * m_extrusion_flow * (wipeTower_box.lu.y() - wipeTower_box.ld.y()), 2400);
|
|
|
|
|
|
|
|
|
|
// The tool is supposed to be active and primed at the time when the wipe tower brim is extruded.
|
|
|
|
|
// Extrude brim around the future wipe tower ('normal' spacing with no extra void space).
|
|
|
|
|
box_coordinates box(wipeTower_box);
|
|
|
|
|
float spacing = m_perimeter_width - m_layer_height*float(1.-M_PI_4);
|
|
|
|
|
|
|
|
|
|
// How many perimeters shall the brim have?
|
|
|
|
|
size_t loops_num = (m_wipe_tower_brim_width + spacing/2.f) / spacing;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < loops_num; ++ i) {
|
|
|
|
|
box.expand(spacing);
|
|
|
|
|
writer.travel (box.ld, 7000)
|
|
|
|
|
.extrude(box.lu, 2100).extrude(box.ru)
|
|
|
|
|
.extrude(box.rd ).extrude(box.ld);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save actual brim width to be later passed to the Print object, which will use it
|
|
|
|
|
// for skirt calculation and pass it to GLCanvas for precise preview box
|
|
|
|
|
m_wipe_tower_brim_width_real = wipeTower_box.ld.x() - box.ld.x() + spacing/2.f;
|
|
|
|
|
|
|
|
|
|
box.expand(-spacing);
|
|
|
|
|
writer.add_wipe_point(writer.x(), writer.y())
|
|
|
|
|
.add_wipe_point(box.ld)
|
|
|
|
|
.add_wipe_point(box.rd);
|
|
|
|
|
|
|
|
|
|
writer.append("; CP WIPE TOWER FIRST LAYER BRIM END\n"
|
|
|
|
|
";-----------------------------------\n");
|
|
|
|
|
|
|
|
|
|
m_print_brim = false; // Mark the brim as extruded
|
|
|
|
|
|
|
|
|
|
// Ask our writer about how much material was consumed:
|
|
|
|
|
if (m_current_tool < m_used_filament_length.size())
|
|
|
|
|
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
|
|
|
|
|
|
|
|
|
return construct_tcr(writer, false, old_tool);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
|
|
|
|
|
void WipeTower::toolchange_Unload(
|
|
|
|
@ -957,7 +882,7 @@ void WipeTower::toolchange_Unload(
|
|
|
|
|
// be already set and there is no need to change anything. Also, the temperature could be changed
|
|
|
|
|
// for wrong extruder.
|
|
|
|
|
if (m_semm) {
|
|
|
|
|
if (new_temperature != 0 && (new_temperature != m_old_temperature || m_is_first_layer) ) { // Set the extruder temperature, but don't wait.
|
|
|
|
|
if (new_temperature != 0 && (new_temperature != m_old_temperature || 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);
|
|
|
|
@ -1017,7 +942,10 @@ void WipeTower::toolchange_Change(
|
|
|
|
|
// gcode could have left the extruder somewhere, we cannot just start extruding. We should also inform the
|
|
|
|
|
// postprocessor that we absolutely want to have this in the gcode, even if it thought it is the same as before.
|
|
|
|
|
Vec2f current_pos = writer.pos_rotated();
|
|
|
|
|
writer.append(std::string("G1 X") + std::to_string(current_pos.x()) + " Y" + std::to_string(current_pos.y()) + never_skip_tag() + "\n");
|
|
|
|
|
writer.feedrate(m_travel_speed * 60.f) // see https://github.com/prusa3d/PrusaSlicer/issues/5483
|
|
|
|
|
.append(std::string("G1 X") + std::to_string(current_pos.x())
|
|
|
|
|
+ " Y" + std::to_string(current_pos.y())
|
|
|
|
|
+ never_skip_tag() + "\n");
|
|
|
|
|
|
|
|
|
|
// The toolchange Tn command will be inserted later, only in case that the user does
|
|
|
|
|
// not provide a custom toolchange gcode.
|
|
|
|
@ -1063,9 +991,8 @@ void WipeTower::toolchange_Wipe(
|
|
|
|
|
float wipe_volume)
|
|
|
|
|
{
|
|
|
|
|
// Increase flow on first layer, slow down print.
|
|
|
|
|
writer.set_extrusion_flow(m_extrusion_flow * (m_is_first_layer ? 1.18f : 1.f))
|
|
|
|
|
writer.set_extrusion_flow(m_extrusion_flow * (is_first_layer() ? 1.18f : 1.f))
|
|
|
|
|
.append("; CP TOOLCHANGE WIPE\n");
|
|
|
|
|
float wipe_coeff = m_is_first_layer ? 0.5f : 1.f;
|
|
|
|
|
const float& xl = cleaning_box.ld.x();
|
|
|
|
|
const float& xr = cleaning_box.rd.x();
|
|
|
|
|
|
|
|
|
@ -1075,7 +1002,9 @@ void WipeTower::toolchange_Wipe(
|
|
|
|
|
|
|
|
|
|
float x_to_wipe = volume_to_length(wipe_volume, m_perimeter_width, m_layer_height);
|
|
|
|
|
float dy = m_extra_spacing*m_perimeter_width;
|
|
|
|
|
float wipe_speed = 1600.f;
|
|
|
|
|
|
|
|
|
|
const float target_speed = is_first_layer() ? m_first_layer_speed * 60.f : 4800.f;
|
|
|
|
|
float wipe_speed = 0.33f * target_speed;
|
|
|
|
|
|
|
|
|
|
// if there is less than 2.5*m_perimeter_width to the edge, advance straightaway (there is likely a blob anyway)
|
|
|
|
|
if ((m_left_to_right ? xr-writer.x() : writer.x()-xl) < 2.5f*m_perimeter_width) {
|
|
|
|
@ -1086,17 +1015,17 @@ void WipeTower::toolchange_Wipe(
|
|
|
|
|
// now the wiping itself:
|
|
|
|
|
for (int i = 0; true; ++i) {
|
|
|
|
|
if (i!=0) {
|
|
|
|
|
if (wipe_speed < 1610.f) wipe_speed = 1800.f;
|
|
|
|
|
else if (wipe_speed < 1810.f) wipe_speed = 2200.f;
|
|
|
|
|
else if (wipe_speed < 2210.f) wipe_speed = 4200.f;
|
|
|
|
|
else wipe_speed = std::min(4800.f, wipe_speed + 50.f);
|
|
|
|
|
if (wipe_speed < 0.34f * target_speed) wipe_speed = 0.375f * target_speed;
|
|
|
|
|
else if (wipe_speed < 0.377 * target_speed) wipe_speed = 0.458f * target_speed;
|
|
|
|
|
else if (wipe_speed < 0.46f * target_speed) wipe_speed = 0.875f * target_speed;
|
|
|
|
|
else wipe_speed = std::min(target_speed, wipe_speed + 50.f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float traversed_x = writer.x();
|
|
|
|
|
if (m_left_to_right)
|
|
|
|
|
writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff);
|
|
|
|
|
writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed);
|
|
|
|
|
else
|
|
|
|
|
writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff);
|
|
|
|
|
writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed);
|
|
|
|
|
|
|
|
|
|
if (writer.y()+float(EPSILON) > cleaning_box.lu.y()-0.5f*m_perimeter_width)
|
|
|
|
|
break; // in case next line would not fit
|
|
|
|
@ -1112,17 +1041,16 @@ void WipeTower::toolchange_Wipe(
|
|
|
|
|
m_left_to_right = !m_left_to_right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this is neither priming nor not the last toolchange on this layer - we are
|
|
|
|
|
// going back to the model - wipe the nozzle.
|
|
|
|
|
if (m_layer_info != m_plan.end() && m_current_tool != m_layer_info->tool_changes.back().new_tool) {
|
|
|
|
|
// We may be going back to the model - wipe the nozzle. If this is followed
|
|
|
|
|
// by finish_layer, this wipe path will be overwritten.
|
|
|
|
|
writer.add_wipe_point(writer.x(), writer.y())
|
|
|
|
|
.add_wipe_point(writer.x(), writer.y() - dy)
|
|
|
|
|
.add_wipe_point(! m_left_to_right ? m_wipe_tower_width : 0.f, writer.y() - dy);
|
|
|
|
|
|
|
|
|
|
if (m_layer_info != m_plan.end() && m_current_tool != m_layer_info->tool_changes.back().new_tool)
|
|
|
|
|
m_left_to_right = !m_left_to_right;
|
|
|
|
|
writer.add_wipe_point(writer.x(), writer.y())
|
|
|
|
|
.add_wipe_point(writer.x(), writer.y() - dy)
|
|
|
|
|
.add_wipe_point(m_left_to_right ? m_wipe_tower_width : 0.f, writer.y() - dy);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writer.set_extrusion_flow(m_extrusion_flow); // Reset the extrusion flow.
|
|
|
|
|
writer.set_extrusion_flow(m_extrusion_flow); // Reset the extrusion flow.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1130,9 +1058,8 @@ void WipeTower::toolchange_Wipe(
|
|
|
|
|
|
|
|
|
|
WipeTower::ToolChangeResult WipeTower::finish_layer()
|
|
|
|
|
{
|
|
|
|
|
// This should only be called if the layer is not finished yet.
|
|
|
|
|
// Otherwise the caller would likely travel to the wipe tower in vain.
|
|
|
|
|
assert(! this->layer_finished());
|
|
|
|
|
m_current_layer_finished = true;
|
|
|
|
|
|
|
|
|
|
size_t old_tool = m_current_tool;
|
|
|
|
|
|
|
|
|
@ -1140,61 +1067,75 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
|
|
|
|
writer.set_extrusion_flow(m_extrusion_flow)
|
|
|
|
|
.set_z(m_z_pos)
|
|
|
|
|
.set_initial_tool(m_current_tool)
|
|
|
|
|
.set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f))
|
|
|
|
|
.append(";--------------------\n"
|
|
|
|
|
"; CP EMPTY GRID START\n")
|
|
|
|
|
.comment_with_value(" layer #", m_num_layer_changes + 1);
|
|
|
|
|
.set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED ? m_layer_info->toolchanges_depth() : 0.f));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Slow down on the 1st layer.
|
|
|
|
|
float speed_factor = m_is_first_layer ? 0.5f : 1.f;
|
|
|
|
|
bool first_layer = is_first_layer();
|
|
|
|
|
float feedrate = first_layer ? m_first_layer_speed * 60.f : 2900.f;
|
|
|
|
|
float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth();
|
|
|
|
|
box_coordinates fill_box(Vec2f(m_perimeter_width, m_depth_traversed + m_perimeter_width),
|
|
|
|
|
m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width);
|
|
|
|
|
box_coordinates fill_box(Vec2f(m_perimeter_width, m_layer_info->depth-(current_depth-m_perimeter_width)),
|
|
|
|
|
m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.set_initial_position((m_left_to_right ? fill_box.ru : fill_box.lu), // so there is never a diagonal travel
|
|
|
|
|
m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation);
|
|
|
|
|
|
|
|
|
|
bool toolchanges_on_layer = m_layer_info->toolchanges_depth() > WT_EPSILON;
|
|
|
|
|
box_coordinates box = fill_box;
|
|
|
|
|
for (int i=0;i<2;++i) {
|
|
|
|
|
if (! toolchanges_on_layer) {
|
|
|
|
|
if (i==0) box.expand(m_perimeter_width);
|
|
|
|
|
else box.expand(-m_perimeter_width);
|
|
|
|
|
}
|
|
|
|
|
else i=2; // only draw the inner perimeter, outer has been already drawn by tool_change(...)
|
|
|
|
|
writer.rectangle(box.ld, box.rd.x()-box.ld.x(), box.ru.y()-box.rd.y(), 2900*speed_factor);
|
|
|
|
|
}
|
|
|
|
|
box_coordinates wt_box(Vec2f(0.f, (m_current_shape == SHAPE_REVERSED ? m_layer_info->toolchanges_depth() : 0.f)),
|
|
|
|
|
m_wipe_tower_width, m_layer_info->depth + m_perimeter_width);
|
|
|
|
|
|
|
|
|
|
// inner perimeter of the sparse section, if there is space for it:
|
|
|
|
|
if (fill_box.ru.y() - fill_box.rd.y() > m_perimeter_width - WT_EPSILON)
|
|
|
|
|
writer.rectangle(fill_box.ld, fill_box.rd.x()-fill_box.ld.x(), fill_box.ru.y()-fill_box.rd.y(), feedrate);
|
|
|
|
|
|
|
|
|
|
// we are in one of the corners, travel to ld along the perimeter:
|
|
|
|
|
if (writer.x() > fill_box.ld.x()+EPSILON) writer.travel(fill_box.ld.x(),writer.y());
|
|
|
|
|
if (writer.y() > fill_box.ld.y()+EPSILON) writer.travel(writer.x(),fill_box.ld.y());
|
|
|
|
|
|
|
|
|
|
if (m_is_first_layer && m_adhesion) {
|
|
|
|
|
// Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower.
|
|
|
|
|
box.expand(-m_perimeter_width/2.f);
|
|
|
|
|
int nsteps = int(floor((box.lu.y() - box.ld.y()) / (2*m_perimeter_width)));
|
|
|
|
|
float step = (box.lu.y() - box.ld.y()) / nsteps;
|
|
|
|
|
writer.travel(box.ld - Vec2f(m_perimeter_width/2.f, m_perimeter_width/2.f));
|
|
|
|
|
if (nsteps >= 0)
|
|
|
|
|
for (int i = 0; i < nsteps; ++i) {
|
|
|
|
|
writer.extrude(box.ld.x()+m_perimeter_width/2.f, writer.y() + 0.5f * step);
|
|
|
|
|
writer.extrude(box.rd.x() - m_perimeter_width / 2.f, writer.y());
|
|
|
|
|
writer.extrude(box.rd.x() - m_perimeter_width / 2.f, writer.y() + 0.5f * step);
|
|
|
|
|
writer.extrude(box.ld.x() + m_perimeter_width / 2.f, writer.y());
|
|
|
|
|
// Extrude infill to support the material to be printed above.
|
|
|
|
|
const float dy = (fill_box.lu.y() - fill_box.ld.y() - m_perimeter_width);
|
|
|
|
|
float left = fill_box.lu.x() + 2*m_perimeter_width;
|
|
|
|
|
float right = fill_box.ru.x() - 2 * m_perimeter_width;
|
|
|
|
|
if (dy > m_perimeter_width)
|
|
|
|
|
{
|
|
|
|
|
writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f))
|
|
|
|
|
.append(";--------------------\n"
|
|
|
|
|
"; CP EMPTY GRID START\n")
|
|
|
|
|
.comment_with_value(" layer #", m_num_layer_changes + 1);
|
|
|
|
|
|
|
|
|
|
// Is there a soluble filament wiped/rammed at the next layer?
|
|
|
|
|
// If so, the infill should not be sparse.
|
|
|
|
|
bool solid_infill = m_layer_info+1 == m_plan.end()
|
|
|
|
|
? false
|
|
|
|
|
: std::any_of((m_layer_info+1)->tool_changes.begin(),
|
|
|
|
|
(m_layer_info+1)->tool_changes.end(),
|
|
|
|
|
[this](const WipeTowerInfo::ToolChange& tch) {
|
|
|
|
|
return m_filpar[tch.new_tool].is_soluble
|
|
|
|
|
|| m_filpar[tch.old_tool].is_soluble;
|
|
|
|
|
});
|
|
|
|
|
solid_infill |= first_layer && m_adhesion;
|
|
|
|
|
|
|
|
|
|
if (solid_infill) {
|
|
|
|
|
float sparse_factor = 1.5f; // 1=solid, 2=every other line, etc.
|
|
|
|
|
if (first_layer) { // the infill should touch perimeters
|
|
|
|
|
left -= m_perimeter_width;
|
|
|
|
|
right += m_perimeter_width;
|
|
|
|
|
sparse_factor = 1.f;
|
|
|
|
|
}
|
|
|
|
|
writer.add_wipe_point(writer.x(), writer.y())
|
|
|
|
|
.add_wipe_point(box.rd.x()-m_perimeter_width/2.f,writer.y());
|
|
|
|
|
}
|
|
|
|
|
else { // Extrude a sparse infill to support the material to be printed above.
|
|
|
|
|
const float dy = (fill_box.lu.y() - fill_box.ld.y() - m_perimeter_width);
|
|
|
|
|
const float left = fill_box.lu.x() + 2*m_perimeter_width;
|
|
|
|
|
const float right = fill_box.ru.x() - 2 * m_perimeter_width;
|
|
|
|
|
if (dy > m_perimeter_width)
|
|
|
|
|
{
|
|
|
|
|
// Extrude an inverse U at the left of the region.
|
|
|
|
|
writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f))
|
|
|
|
|
.extrude(fill_box.lu + Vec2f(m_perimeter_width * 2, 0.f), 2900 * speed_factor);
|
|
|
|
|
float y = fill_box.ld.y() + m_perimeter_width;
|
|
|
|
|
int n = dy / (m_perimeter_width * sparse_factor);
|
|
|
|
|
float spacing = (dy-m_perimeter_width)/(n-1);
|
|
|
|
|
int i=0;
|
|
|
|
|
for (i=0; i<n; ++i) {
|
|
|
|
|
writer.extrude(writer.x(), y, feedrate)
|
|
|
|
|
.extrude(i%2 ? left : right, y);
|
|
|
|
|
y = y + spacing;
|
|
|
|
|
}
|
|
|
|
|
writer.extrude(writer.x(), fill_box.lu.y());
|
|
|
|
|
} else {
|
|
|
|
|
// Extrude an inverse U at the left of the region and the sparse infill.
|
|
|
|
|
writer.extrude(fill_box.lu + Vec2f(m_perimeter_width * 2, 0.f), feedrate);
|
|
|
|
|
|
|
|
|
|
const int n = 1+int((right-left)/m_bridging);
|
|
|
|
|
const float dx = (right-left)/n;
|
|
|
|
@ -1203,18 +1144,40 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
|
|
|
|
writer.travel(x,writer.y());
|
|
|
|
|
writer.extrude(x,i%2 ? fill_box.rd.y() : fill_box.ru.y());
|
|
|
|
|
}
|
|
|
|
|
writer.add_wipe_point(Vec2f(writer.x(), writer.y()))
|
|
|
|
|
.add_wipe_point(Vec2f(left, writer.y()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
writer.add_wipe_point(Vec2f(writer.x(), writer.y()))
|
|
|
|
|
.add_wipe_point(Vec2f(right, writer.y()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
writer.append("; CP EMPTY GRID END\n"
|
|
|
|
|
";------------------\n\n\n\n\n\n\n");
|
|
|
|
|
|
|
|
|
|
m_depth_traversed = m_wipe_tower_depth-m_perimeter_width;
|
|
|
|
|
writer.append("; CP EMPTY GRID END\n"
|
|
|
|
|
";------------------\n\n\n\n\n\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// outer perimeter (always):
|
|
|
|
|
writer.rectangle(wt_box, feedrate);
|
|
|
|
|
|
|
|
|
|
// brim (first layer only)
|
|
|
|
|
if (first_layer) {
|
|
|
|
|
box_coordinates box = wt_box;
|
|
|
|
|
float spacing = m_perimeter_width - m_layer_height*float(1.-M_PI_4);
|
|
|
|
|
// How many perimeters shall the brim have?
|
|
|
|
|
size_t loops_num = (m_wipe_tower_brim_width + spacing/2.f) / spacing;
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < loops_num; ++ i) {
|
|
|
|
|
box.expand(spacing);
|
|
|
|
|
writer.rectangle(box);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save actual brim width to be later passed to the Print object, which will use it
|
|
|
|
|
// for skirt calculation and pass it to GLCanvas for precise preview box
|
|
|
|
|
m_wipe_tower_brim_width_real = wt_box.ld.x() - box.ld.x() + spacing/2.f;
|
|
|
|
|
wt_box = box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now prepare future wipe. box contains rectangle that was extruded last (ccw).
|
|
|
|
|
Vec2f target = (writer.pos() == wt_box.ld ? wt_box.rd :
|
|
|
|
|
(writer.pos() == wt_box.rd ? wt_box.ru :
|
|
|
|
|
(writer.pos() == wt_box.ru ? wt_box.lu :
|
|
|
|
|
wt_box.ld)));
|
|
|
|
|
writer.add_wipe_point(writer.pos())
|
|
|
|
|
.add_wipe_point(target);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Ask our writer about how much material was consumed.
|
|
|
|
@ -1227,23 +1190,22 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box
|
|
|
|
|
void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, bool brim, float wipe_volume)
|
|
|
|
|
void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool,
|
|
|
|
|
unsigned int new_tool, float wipe_volume)
|
|
|
|
|
{
|
|
|
|
|
assert(m_plan.empty() || m_plan.back().z <= z_par + WT_EPSILON); // refuses to add a layer below the last one
|
|
|
|
|
|
|
|
|
|
if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first
|
|
|
|
|
m_plan.push_back(WipeTowerInfo(z_par, layer_height_par));
|
|
|
|
|
|
|
|
|
|
if (brim) { // this toolchange prints brim - we must add it to m_plan, but not to count its depth
|
|
|
|
|
m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (m_first_layer_idx == size_t(-1) && (! m_no_sparse_layers || old_tool != new_tool))
|
|
|
|
|
m_first_layer_idx = m_plan.size() - 1;
|
|
|
|
|
|
|
|
|
|
if (old_tool==new_tool) // new layer without toolchanges - we are done
|
|
|
|
|
return;
|
|
|
|
|
if (old_tool == new_tool) // new layer without toolchanges - we are done
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// this is an actual toolchange - let's calculate depth to reserve on the wipe tower
|
|
|
|
|
float depth = 0.f;
|
|
|
|
|
float depth = 0.f;
|
|
|
|
|
float width = m_wipe_tower_width - 3*m_perimeter_width;
|
|
|
|
|
float length_to_extrude = volume_to_length(0.25f * std::accumulate(m_filpar[old_tool].ramming_speed.begin(), m_filpar[old_tool].ramming_speed.end(), 0.f),
|
|
|
|
|
m_perimeter_width * m_filpar[old_tool].ramming_line_width_multiplicator,
|
|
|
|
@ -1293,28 +1255,65 @@ void WipeTower::save_on_last_wipe()
|
|
|
|
|
if (m_layer_info->tool_changes.size()==0) // we have no way to save anything on an empty layer
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (const auto &toolchange : m_layer_info->tool_changes)
|
|
|
|
|
// Which toolchange will finish_layer extrusions be subtracted from?
|
|
|
|
|
int idx = first_toolchange_to_nonsoluble(m_layer_info->tool_changes);
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<int(m_layer_info->tool_changes.size()); ++i) {
|
|
|
|
|
auto& toolchange = m_layer_info->tool_changes[i];
|
|
|
|
|
tool_change(toolchange.new_tool);
|
|
|
|
|
|
|
|
|
|
float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into
|
|
|
|
|
float length_to_save = 2*(m_wipe_tower_width+m_wipe_tower_depth) + (!layer_finished() ? finish_layer().total_extrusion_length_in_plane() : 0.f);
|
|
|
|
|
float length_to_wipe = volume_to_length(m_layer_info->tool_changes.back().wipe_volume,
|
|
|
|
|
m_perimeter_width,m_layer_info->height) - m_layer_info->tool_changes.back().first_wipe_line - length_to_save;
|
|
|
|
|
if (i == idx) {
|
|
|
|
|
float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into
|
|
|
|
|
float length_to_save = finish_layer().total_extrusion_length_in_plane();
|
|
|
|
|
float length_to_wipe = volume_to_length(toolchange.wipe_volume,
|
|
|
|
|
m_perimeter_width, m_layer_info->height) - toolchange.first_wipe_line - length_to_save;
|
|
|
|
|
|
|
|
|
|
length_to_wipe = std::max(length_to_wipe,0.f);
|
|
|
|
|
float depth_to_wipe = m_perimeter_width * (std::floor(length_to_wipe/width) + ( length_to_wipe > 0.f ? 1.f : 0.f ) ) * m_extra_spacing;
|
|
|
|
|
length_to_wipe = std::max(length_to_wipe,0.f);
|
|
|
|
|
float depth_to_wipe = m_perimeter_width * (std::floor(length_to_wipe/width) + ( length_to_wipe > 0.f ? 1.f : 0.f ) ) * m_extra_spacing;
|
|
|
|
|
|
|
|
|
|
//depth += (int(length_to_extrude / width) + 1) * m_perimeter_width;
|
|
|
|
|
m_layer_info->tool_changes.back().required_depth = m_layer_info->tool_changes.back().ramming_depth + depth_to_wipe;
|
|
|
|
|
toolchange.required_depth = toolchange.ramming_depth + depth_to_wipe;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Return index of first toolchange that switches to non-soluble extruder
|
|
|
|
|
// ot -1 if there is no such toolchange.
|
|
|
|
|
int WipeTower::first_toolchange_to_nonsoluble(
|
|
|
|
|
const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const
|
|
|
|
|
{
|
|
|
|
|
for (size_t idx=0; idx<tool_changes.size(); ++idx)
|
|
|
|
|
if (! m_filpar[tool_changes[idx].new_tool].is_soluble)
|
|
|
|
|
return idx;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static WipeTower::ToolChangeResult merge_tcr(WipeTower::ToolChangeResult& first,
|
|
|
|
|
WipeTower::ToolChangeResult& second)
|
|
|
|
|
{
|
|
|
|
|
assert(first.new_tool == second.initial_tool);
|
|
|
|
|
WipeTower::ToolChangeResult out = first;
|
|
|
|
|
if (first.end_pos != second.start_pos) {
|
|
|
|
|
char buf[2048]; // Add a travel move from tc1.end_pos to tc2.start_pos.
|
|
|
|
|
sprintf(buf, "G1 X%.3f Y%.3f F7200\n", second.start_pos.x(), second.start_pos.y());
|
|
|
|
|
out.gcode += buf;
|
|
|
|
|
}
|
|
|
|
|
out.gcode += second.gcode;
|
|
|
|
|
out.extrusions.insert(out.extrusions.end(), second.extrusions.begin(), second.extrusions.end());
|
|
|
|
|
out.end_pos = second.end_pos;
|
|
|
|
|
out.wipe_path = second.wipe_path;
|
|
|
|
|
out.initial_tool = first.initial_tool;
|
|
|
|
|
out.new_tool = second.new_tool;
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Processes vector m_plan and calls respective functions to generate G-code for the wipe tower
|
|
|
|
|
// Resulting ToolChangeResults are appended into vector "result"
|
|
|
|
|
void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result)
|
|
|
|
|
{
|
|
|
|
|
if (m_plan.empty())
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_extra_spacing = 1.f;
|
|
|
|
@ -1325,9 +1324,6 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
|
|
|
|
|
plan_tower();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_peters_wipe_tower)
|
|
|
|
|
make_wipe_tower_square();
|
|
|
|
|
|
|
|
|
|
m_layer_info = m_plan.begin();
|
|
|
|
|
|
|
|
|
|
// we don't know which extruder to start with - we'll set it according to the first toolchange
|
|
|
|
@ -1346,65 +1342,41 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
|
|
|
|
|
std::vector<WipeTower::ToolChangeResult> layer_result;
|
|
|
|
|
for (auto layer : m_plan)
|
|
|
|
|
{
|
|
|
|
|
set_layer(layer.z,layer.height,0,layer.z == m_plan.front().z,layer.z == m_plan.back().z);
|
|
|
|
|
if (m_peters_wipe_tower)
|
|
|
|
|
m_internal_rotation += 90.f;
|
|
|
|
|
else
|
|
|
|
|
m_internal_rotation += 180.f;
|
|
|
|
|
set_layer(layer.z, layer.height, 0, false/*layer.z == m_plan.front().z*/, layer.z == m_plan.back().z);
|
|
|
|
|
m_internal_rotation += 180.f;
|
|
|
|
|
|
|
|
|
|
if (!m_peters_wipe_tower && m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width)
|
|
|
|
|
if (m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width)
|
|
|
|
|
m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f;
|
|
|
|
|
|
|
|
|
|
for (const auto &toolchange : layer.tool_changes)
|
|
|
|
|
layer_result.emplace_back(tool_change(toolchange.new_tool));
|
|
|
|
|
int idx = first_toolchange_to_nonsoluble(layer.tool_changes);
|
|
|
|
|
ToolChangeResult finish_layer_tcr;
|
|
|
|
|
|
|
|
|
|
if (! layer_finished()) {
|
|
|
|
|
auto finish_layer_toolchange = finish_layer();
|
|
|
|
|
if ( ! layer.tool_changes.empty() ) { // we will merge it to the last toolchange
|
|
|
|
|
auto& last_toolchange = layer_result.back();
|
|
|
|
|
if (last_toolchange.end_pos != finish_layer_toolchange.start_pos) {
|
|
|
|
|
char buf[2048]; // Add a travel move from tc1.end_pos to tc2.start_pos.
|
|
|
|
|
sprintf(buf, "G1 X%.3f Y%.3f F7200\n", finish_layer_toolchange.start_pos.x(), finish_layer_toolchange.start_pos.y());
|
|
|
|
|
last_toolchange.gcode += buf;
|
|
|
|
|
}
|
|
|
|
|
last_toolchange.gcode += finish_layer_toolchange.gcode;
|
|
|
|
|
last_toolchange.extrusions.insert(last_toolchange.extrusions.end(), finish_layer_toolchange.extrusions.begin(), finish_layer_toolchange.extrusions.end());
|
|
|
|
|
last_toolchange.end_pos = finish_layer_toolchange.end_pos;
|
|
|
|
|
last_toolchange.wipe_path = finish_layer_toolchange.wipe_path;
|
|
|
|
|
}
|
|
|
|
|
if (idx == -1) {
|
|
|
|
|
// if there is no toolchange switching to non-soluble, finish layer
|
|
|
|
|
// will be called at the very beginning. That's the last possibility
|
|
|
|
|
// where a nonsoluble tool can be.
|
|
|
|
|
finish_layer_tcr = finish_layer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<int(layer.tool_changes.size()); ++i) {
|
|
|
|
|
layer_result.emplace_back(tool_change(layer.tool_changes[i].new_tool));
|
|
|
|
|
if (i == idx) // finish_layer will be called after this toolchange
|
|
|
|
|
finish_layer_tcr = finish_layer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (layer_result.empty()) {
|
|
|
|
|
// there is nothing to merge finish_layer with
|
|
|
|
|
layer_result.emplace_back(std::move(finish_layer_tcr));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (idx == -1)
|
|
|
|
|
layer_result[0] = merge_tcr(finish_layer_tcr, layer_result[0]);
|
|
|
|
|
else
|
|
|
|
|
layer_result.emplace_back(std::move(finish_layer_toolchange));
|
|
|
|
|
layer_result[idx] = merge_tcr(layer_result[idx], finish_layer_tcr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.emplace_back(std::move(layer_result));
|
|
|
|
|
m_is_first_layer = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WipeTower::make_wipe_tower_square()
|
|
|
|
|
{
|
|
|
|
|
const float width = m_wipe_tower_width - 3 * m_perimeter_width;
|
|
|
|
|
const float depth = m_wipe_tower_depth - m_perimeter_width;
|
|
|
|
|
// area that we actually print into is width*depth
|
|
|
|
|
float side = sqrt(depth * width);
|
|
|
|
|
|
|
|
|
|
m_wipe_tower_width = side + 3 * m_perimeter_width;
|
|
|
|
|
m_wipe_tower_depth = side + 2 * m_perimeter_width;
|
|
|
|
|
// For all layers, find how depth changed and update all toolchange depths
|
|
|
|
|
for (auto &lay : m_plan)
|
|
|
|
|
{
|
|
|
|
|
side = sqrt(lay.depth * width);
|
|
|
|
|
float width_ratio = width / side;
|
|
|
|
|
|
|
|
|
|
//lay.extra_spacing = width_ratio;
|
|
|
|
|
for (auto &tch : lay.tool_changes)
|
|
|
|
|
tch.required_depth *= width_ratio;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plan_tower(); // propagates depth downwards again (width has changed)
|
|
|
|
|
for (auto& lay : m_plan) // depths set, now the spacing
|
|
|
|
|
lay.extra_spacing = lay.depth / lay.toolchanges_depth();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Slic3r
|
|
|
|
|