mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 18:27:58 -06:00
Wipe tower: refactoring of brim and solid infill on first layer
This commit is contained in:
parent
f6de946dd7
commit
a6ddab856b
5 changed files with 145 additions and 229 deletions
|
@ -435,19 +435,18 @@ namespace Slic3r {
|
||||||
{
|
{
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
assert(m_layer_idx >= 0);
|
assert(m_layer_idx >= 0);
|
||||||
if (!m_brim_done || gcodegen.writer().need_toolchange(extruder_id) || finish_layer) {
|
if (gcodegen.writer().need_toolchange(extruder_id) || finish_layer) {
|
||||||
if (m_layer_idx < (int)m_tool_changes.size()) {
|
if (m_layer_idx < (int)m_tool_changes.size()) {
|
||||||
if (!(size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size()))
|
if (!(size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size()))
|
||||||
throw Slic3r::RuntimeError("Wipe tower generation failed, possibly due to empty first layer.");
|
throw Slic3r::RuntimeError("Wipe tower generation failed, possibly due to empty first layer.");
|
||||||
|
|
||||||
|
|
||||||
// Calculate where the wipe tower layer will be printed. -1 means that print z will not change,
|
// Calculate where the wipe tower layer will be printed. -1 means that print z will not change,
|
||||||
// resulting in a wipe tower with sparse layers.
|
// resulting in a wipe tower with sparse layers.
|
||||||
double wipe_tower_z = -1;
|
double wipe_tower_z = -1;
|
||||||
bool ignore_sparse = false;
|
bool ignore_sparse = false;
|
||||||
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
|
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
|
||||||
wipe_tower_z = m_last_wipe_tower_print_z;
|
wipe_tower_z = m_last_wipe_tower_print_z;
|
||||||
ignore_sparse = (m_brim_done && m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool);
|
ignore_sparse = (m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool);
|
||||||
if (m_tool_change_idx == 0 && !ignore_sparse)
|
if (m_tool_change_idx == 0 && !ignore_sparse)
|
||||||
wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height;
|
wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height;
|
||||||
}
|
}
|
||||||
|
@ -457,7 +456,6 @@ namespace Slic3r {
|
||||||
m_last_wipe_tower_print_z = wipe_tower_z;
|
m_last_wipe_tower_print_z = wipe_tower_z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_brim_done = true;
|
|
||||||
}
|
}
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,8 @@ public:
|
||||||
m_tool_changes(tool_changes),
|
m_tool_changes(tool_changes),
|
||||||
m_final_purge(final_purge),
|
m_final_purge(final_purge),
|
||||||
m_layer_idx(-1),
|
m_layer_idx(-1),
|
||||||
m_tool_change_idx(0),
|
m_tool_change_idx(0)
|
||||||
m_brim_done(false) {}
|
{}
|
||||||
|
|
||||||
std::string prime(GCode &gcodegen);
|
std::string prime(GCode &gcodegen);
|
||||||
void next_layer() { ++ m_layer_idx; m_tool_change_idx = 0; }
|
void next_layer() { ++ m_layer_idx; m_tool_change_idx = 0; }
|
||||||
|
@ -105,8 +105,6 @@ private:
|
||||||
// Current layer index.
|
// Current layer index.
|
||||||
int m_layer_idx;
|
int m_layer_idx;
|
||||||
int m_tool_change_idx;
|
int m_tool_change_idx;
|
||||||
bool m_brim_done;
|
|
||||||
bool i_have_brim = false;
|
|
||||||
double m_last_wipe_tower_print_z = 0.f;
|
double m_last_wipe_tower_print_z = 0.f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,14 @@ public:
|
||||||
return (*this);
|
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)
|
WipeTowerWriter& load(float e, float f = 0.f)
|
||||||
{
|
{
|
||||||
if (e == 0.f && (f == 0.f || f == m_current_feedrate))
|
if (e == 0.f && (f == 0.f || f == m_current_feedrate))
|
||||||
|
@ -512,7 +520,6 @@ WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<fl
|
||||||
m_wipe_tower_brim_width(float(config.wipe_tower_brim_width)),
|
m_wipe_tower_brim_width(float(config.wipe_tower_brim_width)),
|
||||||
m_y_shift(0.f),
|
m_y_shift(0.f),
|
||||||
m_z_pos(0.f),
|
m_z_pos(0.f),
|
||||||
m_is_first_layer(false),
|
|
||||||
m_bridging(float(config.wipe_tower_bridging)),
|
m_bridging(float(config.wipe_tower_bridging)),
|
||||||
m_no_sparse_layers(config.wipe_tower_no_sparse_layers),
|
m_no_sparse_layers(config.wipe_tower_no_sparse_layers),
|
||||||
m_gcode_flavor(config.gcode_flavor),
|
m_gcode_flavor(config.gcode_flavor),
|
||||||
|
@ -684,21 +691,15 @@ 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
|
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)
|
// 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;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
||||||
{
|
{
|
||||||
if ( m_print_brim )
|
|
||||||
return toolchange_Brim();
|
|
||||||
|
|
||||||
size_t old_tool = m_current_tool;
|
size_t old_tool = m_current_tool;
|
||||||
|
bool first_layer = m_layer_info == m_plan.begin();
|
||||||
|
|
||||||
float wipe_area = 0.f;
|
float wipe_area = 0.f;
|
||||||
bool last_change_in_layer = false;
|
|
||||||
float wipe_volume = 0.f;
|
float wipe_volume = 0.f;
|
||||||
|
|
||||||
// Finds this toolchange info
|
// Finds this toolchange info
|
||||||
|
@ -707,8 +708,6 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
||||||
for (const auto &b : m_layer_info->tool_changes)
|
for (const auto &b : m_layer_info->tool_changes)
|
||||||
if ( b.new_tool == tool ) {
|
if ( b.new_tool == tool ) {
|
||||||
wipe_volume = b.wipe_volume;
|
wipe_volume = b.wipe_volume;
|
||||||
if (tool == m_layer_info->tool_changes.back().new_tool)
|
|
||||||
last_change_in_layer = true;
|
|
||||||
wipe_area = b.required_depth * m_layer_info->extra_spacing;
|
wipe_area = b.required_depth * m_layer_info->extra_spacing;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -749,7 +748,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.
|
// 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.
|
if (tool != (unsigned int)-1){ // This is not the last change.
|
||||||
toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material,
|
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);
|
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_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials.
|
||||||
toolchange_Load(writer, cleaning_box);
|
toolchange_Load(writer, cleaning_box);
|
||||||
writer.travel(writer.x(), writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road
|
writer.travel(writer.x(), writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road
|
||||||
|
@ -760,16 +759,6 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
||||||
|
|
||||||
m_depth_traversed += wipe_area;
|
m_depth_traversed += wipe_area;
|
||||||
|
|
||||||
/*if (last_change_in_layer) {// draw perimeter line
|
|
||||||
writer.set_y_shift(m_y_shift);
|
|
||||||
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)
|
if (m_set_extruder_trimpot)
|
||||||
writer.set_extruder_trimpot(550); // Reset the extruder current to a normal value.
|
writer.set_extruder_trimpot(550); // Reset the extruder current to a normal value.
|
||||||
writer.speed_override_restore();
|
writer.speed_override_restore();
|
||||||
|
@ -787,66 +776,6 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool)
|
||||||
return construct_tcr(writer, false, old_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.
|
// Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
|
||||||
void WipeTower::toolchange_Unload(
|
void WipeTower::toolchange_Unload(
|
||||||
|
@ -855,6 +784,7 @@ void WipeTower::toolchange_Unload(
|
||||||
const std::string& current_material,
|
const std::string& current_material,
|
||||||
const int new_temperature)
|
const int new_temperature)
|
||||||
{
|
{
|
||||||
|
bool first_layer = m_layer_info == m_plan.begin();
|
||||||
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;
|
||||||
|
|
||||||
|
@ -943,7 +873,7 @@ void WipeTower::toolchange_Unload(
|
||||||
// be already set and there is no need to change anything. Also, the temperature could be changed
|
// be already set and there is no need to change anything. Also, the temperature could be changed
|
||||||
// for wrong extruder.
|
// for wrong extruder.
|
||||||
if (m_semm) {
|
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 || 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)
|
// 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).
|
// 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);
|
writer.set_extruder_temp(new_temperature, false);
|
||||||
|
@ -1049,9 +979,10 @@ void WipeTower::toolchange_Wipe(
|
||||||
float wipe_volume)
|
float wipe_volume)
|
||||||
{
|
{
|
||||||
// Increase flow on first layer, slow down print.
|
// Increase flow on first layer, slow down print.
|
||||||
writer.set_extrusion_flow(m_extrusion_flow * (m_is_first_layer ? 1.18f : 1.f))
|
bool first_layer = m_layer_info == m_plan.begin();
|
||||||
|
writer.set_extrusion_flow(m_extrusion_flow * (first_layer ? 1.18f : 1.f))
|
||||||
.append("; CP TOOLCHANGE WIPE\n");
|
.append("; CP TOOLCHANGE WIPE\n");
|
||||||
float wipe_coeff = m_is_first_layer ? 0.5f : 1.f;
|
float wipe_coeff = first_layer ? 0.5f : 1.f;
|
||||||
const float& xl = cleaning_box.ld.x();
|
const float& xl = cleaning_box.ld.x();
|
||||||
const float& xr = cleaning_box.rd.x();
|
const float& xr = cleaning_box.rd.x();
|
||||||
|
|
||||||
|
@ -1129,7 +1060,8 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
||||||
|
|
||||||
|
|
||||||
// Slow down on the 1st layer.
|
// Slow down on the 1st layer.
|
||||||
float speed_factor = m_is_first_layer ? 0.5f : 1.f;
|
bool first_layer = m_layer_info == m_plan.begin();
|
||||||
|
float speed_factor = first_layer ? 0.5f : 1.f;
|
||||||
float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth();
|
float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth();
|
||||||
box_coordinates fill_box(Vec2f(m_perimeter_width, m_layer_info->depth-(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);
|
m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width);
|
||||||
|
@ -1139,40 +1071,21 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
||||||
m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation);
|
m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation);
|
||||||
|
|
||||||
bool toolchanges_on_layer = m_layer_info->toolchanges_depth() > WT_EPSILON;
|
bool toolchanges_on_layer = m_layer_info->toolchanges_depth() > WT_EPSILON;
|
||||||
|
box_coordinates wipeTower_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:
|
// 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)
|
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(), 2900*speed_factor);
|
writer.rectangle(fill_box.ld, fill_box.rd.x()-fill_box.ld.x(), fill_box.ru.y()-fill_box.rd.y(), 2900*speed_factor);
|
||||||
|
|
||||||
// outer perimeter (always):
|
|
||||||
writer.rectangle(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);
|
|
||||||
|
|
||||||
// we are in one of the corners, travel to ld along the perimeter:
|
// 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.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 (writer.y() > fill_box.ld.y()+EPSILON) writer.travel(writer.x(),fill_box.ld.y());
|
||||||
|
|
||||||
if (m_is_first_layer && m_adhesion) {
|
// Extrude infill to support the material to be printed above.
|
||||||
// Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower.
|
|
||||||
box_coordinates box = fill_box;
|
|
||||||
box.expand(-m_perimeter_width/2.f);
|
|
||||||
int nsteps = int(std::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());
|
|
||||||
}
|
|
||||||
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 dy = (fill_box.lu.y() - fill_box.ld.y() - m_perimeter_width);
|
||||||
const float left = fill_box.lu.x() + 2*m_perimeter_width;
|
float left = fill_box.lu.x() + 2*m_perimeter_width;
|
||||||
const float right = fill_box.ru.x() - 2 * m_perimeter_width;
|
float right = fill_box.ru.x() - 2 * m_perimeter_width;
|
||||||
if (dy > m_perimeter_width)
|
if (dy > m_perimeter_width)
|
||||||
{
|
{
|
||||||
writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f))
|
writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f))
|
||||||
|
@ -1190,13 +1103,19 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
||||||
return m_filpar[tch.new_tool].is_soluble
|
return m_filpar[tch.new_tool].is_soluble
|
||||||
|| m_filpar[tch.old_tool].is_soluble;
|
|| m_filpar[tch.old_tool].is_soluble;
|
||||||
});
|
});
|
||||||
|
solid_infill |= first_layer && m_adhesion;
|
||||||
|
|
||||||
if (solid_infill) {
|
if (solid_infill) {
|
||||||
const float sparse_factor = 1.5f; // 1=solid, 2=every other line, etc.
|
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;
|
||||||
|
}
|
||||||
float y = fill_box.ld.y() + m_perimeter_width;
|
float y = fill_box.ld.y() + m_perimeter_width;
|
||||||
int n = dy / (m_perimeter_width * sparse_factor);
|
int n = dy / (m_perimeter_width * sparse_factor);
|
||||||
float spacing = (dy-m_perimeter_width)/(n-1);
|
float spacing = (dy-m_perimeter_width)/(n-1);
|
||||||
int i = 0;
|
int i=0;
|
||||||
for (i=0; i<n; ++i) {
|
for (i=0; i<n; ++i) {
|
||||||
writer.extrude(writer.x(), y, 2900 * speed_factor)
|
writer.extrude(writer.x(), y, 2900 * speed_factor)
|
||||||
.extrude(i%2 ? left : right, y);
|
.extrude(i%2 ? left : right, y);
|
||||||
|
@ -1206,7 +1125,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
||||||
.add_wipe_point(Vec2f(writer.x(), writer.y()))
|
.add_wipe_point(Vec2f(writer.x(), writer.y()))
|
||||||
.add_wipe_point(Vec2f(i%2 ? left : right, writer.y()));
|
.add_wipe_point(Vec2f(i%2 ? left : right, writer.y()));
|
||||||
} else {
|
} else {
|
||||||
// Extrude an inverse U at the left of the region.
|
// 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), 2900 * speed_factor);
|
writer.extrude(fill_box.lu + Vec2f(m_perimeter_width * 2, 0.f), 2900 * speed_factor);
|
||||||
|
|
||||||
const int n = 1+int((right-left)/m_bridging);
|
const int n = 1+int((right-left)/m_bridging);
|
||||||
|
@ -1227,8 +1146,28 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
||||||
writer.add_wipe_point(Vec2f(writer.x(), writer.y()))
|
writer.add_wipe_point(Vec2f(writer.x(), writer.y()))
|
||||||
.add_wipe_point(Vec2f(right, writer.y()));
|
.add_wipe_point(Vec2f(right, writer.y()));
|
||||||
}
|
}
|
||||||
|
// TODO: - wipe path je potřeba nastavit níž
|
||||||
|
// - kouknout na wipe_tower_error.3mf
|
||||||
|
|
||||||
|
// outer perimeter (always):
|
||||||
|
writer.rectangle(wipeTower_box);
|
||||||
|
|
||||||
|
// brim (first layer only)
|
||||||
|
if (first_layer) {
|
||||||
|
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.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 = wipeTower_box.ld.x() - box.ld.x() + spacing/2.f;
|
||||||
|
}
|
||||||
|
|
||||||
// Ask our writer about how much material was consumed.
|
// Ask our writer about how much material was consumed.
|
||||||
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
||||||
|
@ -1240,18 +1179,14 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box
|
// 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
|
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
|
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));
|
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 (old_tool==new_tool) // new layer without toolchanges - we are done
|
if (old_tool==new_tool) // new layer without toolchanges - we are done
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1365,7 +1300,6 @@ static WipeTower::ToolChangeResult merge_tcr(WipeTower::ToolChangeResult& first,
|
||||||
void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result)
|
void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result)
|
||||||
{
|
{
|
||||||
if (m_plan.empty())
|
if (m_plan.empty())
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_extra_spacing = 1.f;
|
m_extra_spacing = 1.f;
|
||||||
|
@ -1394,7 +1328,7 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
|
||||||
std::vector<WipeTower::ToolChangeResult> layer_result;
|
std::vector<WipeTower::ToolChangeResult> layer_result;
|
||||||
for (auto layer : m_plan)
|
for (auto layer : m_plan)
|
||||||
{
|
{
|
||||||
set_layer(layer.z,layer.height,0,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);
|
||||||
m_internal_rotation += 180.f;
|
m_internal_rotation += 180.f;
|
||||||
|
|
||||||
if (m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width)
|
if (m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width)
|
||||||
|
@ -1428,7 +1362,6 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
|
||||||
}
|
}
|
||||||
|
|
||||||
result.emplace_back(std::move(layer_result));
|
result.emplace_back(std::move(layer_result));
|
||||||
m_is_first_layer = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,37 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct box_coordinates
|
||||||
|
{
|
||||||
|
box_coordinates(float left, float bottom, float width, float height) :
|
||||||
|
ld(left , bottom ),
|
||||||
|
lu(left , bottom + height),
|
||||||
|
rd(left + width, bottom ),
|
||||||
|
ru(left + width, bottom + height) {}
|
||||||
|
box_coordinates(const Vec2f &pos, float width, float height) : box_coordinates(pos(0), pos(1), width, height) {}
|
||||||
|
void translate(const Vec2f &shift) {
|
||||||
|
ld += shift; lu += shift;
|
||||||
|
rd += shift; ru += shift;
|
||||||
|
}
|
||||||
|
void translate(const float dx, const float dy) { translate(Vec2f(dx, dy)); }
|
||||||
|
void expand(const float offset) {
|
||||||
|
ld += Vec2f(- offset, - offset);
|
||||||
|
lu += Vec2f(- offset, offset);
|
||||||
|
rd += Vec2f( offset, - offset);
|
||||||
|
ru += Vec2f( offset, offset);
|
||||||
|
}
|
||||||
|
void expand(const float offset_x, const float offset_y) {
|
||||||
|
ld += Vec2f(- offset_x, - offset_y);
|
||||||
|
lu += Vec2f(- offset_x, offset_y);
|
||||||
|
rd += Vec2f( offset_x, - offset_y);
|
||||||
|
ru += Vec2f( offset_x, offset_y);
|
||||||
|
}
|
||||||
|
Vec2f ld; // left down
|
||||||
|
Vec2f lu; // left upper
|
||||||
|
Vec2f rd; // right lower
|
||||||
|
Vec2f ru; // right upper
|
||||||
|
};
|
||||||
|
|
||||||
// Construct ToolChangeResult from current state of WipeTower and WipeTowerWriter.
|
// Construct ToolChangeResult from current state of WipeTower and WipeTowerWriter.
|
||||||
// WipeTowerWriter is moved from !
|
// WipeTowerWriter is moved from !
|
||||||
ToolChangeResult construct_tcr(WipeTowerWriter& writer,
|
ToolChangeResult construct_tcr(WipeTowerWriter& writer,
|
||||||
|
@ -102,7 +133,7 @@ public:
|
||||||
|
|
||||||
// Appends into internal structure m_plan containing info about the future wipe tower
|
// Appends into internal structure m_plan containing info about the future wipe tower
|
||||||
// to be used before building begins. The entries must be added ordered in z.
|
// to be used before building begins. The entries must be added ordered in z.
|
||||||
void plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, bool brim, float wipe_volume = 0.f);
|
void plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, float wipe_volume = 0.f);
|
||||||
|
|
||||||
// Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result"
|
// Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result"
|
||||||
void generate(std::vector<std::vector<ToolChangeResult>> &result);
|
void generate(std::vector<std::vector<ToolChangeResult>> &result);
|
||||||
|
@ -129,8 +160,6 @@ public:
|
||||||
{
|
{
|
||||||
m_z_pos = print_z;
|
m_z_pos = print_z;
|
||||||
m_layer_height = layer_height;
|
m_layer_height = layer_height;
|
||||||
m_is_first_layer = is_first_layer;
|
|
||||||
m_print_brim = is_first_layer;
|
|
||||||
m_depth_traversed = 0.f;
|
m_depth_traversed = 0.f;
|
||||||
m_current_layer_finished = false;
|
m_current_layer_finished = false;
|
||||||
m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL;
|
m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL;
|
||||||
|
@ -176,10 +205,7 @@ public:
|
||||||
|
|
||||||
// Is the current layer finished?
|
// Is the current layer finished?
|
||||||
bool layer_finished() const {
|
bool layer_finished() const {
|
||||||
return m_current_layer_finished;/*( (m_is_first_layer
|
return m_current_layer_finished;
|
||||||
? m_wipe_tower_depth - m_perimeter_width
|
|
||||||
: m_layer_info->depth
|
|
||||||
) < m_depth_traversed + WT_EPSILON);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float> get_used_filament() const { return m_used_filament_length; }
|
std::vector<float> get_used_filament() const { return m_used_filament_length; }
|
||||||
|
@ -232,7 +258,6 @@ private:
|
||||||
float m_z_pos = 0.f; // Current Z position.
|
float m_z_pos = 0.f; // Current Z position.
|
||||||
float m_layer_height = 0.f; // Current layer height.
|
float m_layer_height = 0.f; // Current layer height.
|
||||||
size_t m_max_color_changes = 0; // Maximum number of color changes per layer.
|
size_t m_max_color_changes = 0; // Maximum number of color changes per layer.
|
||||||
bool m_is_first_layer = false;// Is this the 1st layer of the print? If so, print the brim around the waste tower.
|
|
||||||
int m_old_temperature = -1; // To keep track of what was the last temp that we set (so we don't issue the command when not neccessary)
|
int m_old_temperature = -1; // To keep track of what was the last temp that we set (so we don't issue the command when not neccessary)
|
||||||
|
|
||||||
// G-code generator parameters.
|
// G-code generator parameters.
|
||||||
|
@ -299,38 +324,6 @@ private:
|
||||||
void save_on_last_wipe();
|
void save_on_last_wipe();
|
||||||
|
|
||||||
|
|
||||||
struct box_coordinates
|
|
||||||
{
|
|
||||||
box_coordinates(float left, float bottom, float width, float height) :
|
|
||||||
ld(left , bottom ),
|
|
||||||
lu(left , bottom + height),
|
|
||||||
rd(left + width, bottom ),
|
|
||||||
ru(left + width, bottom + height) {}
|
|
||||||
box_coordinates(const Vec2f &pos, float width, float height) : box_coordinates(pos(0), pos(1), width, height) {}
|
|
||||||
void translate(const Vec2f &shift) {
|
|
||||||
ld += shift; lu += shift;
|
|
||||||
rd += shift; ru += shift;
|
|
||||||
}
|
|
||||||
void translate(const float dx, const float dy) { translate(Vec2f(dx, dy)); }
|
|
||||||
void expand(const float offset) {
|
|
||||||
ld += Vec2f(- offset, - offset);
|
|
||||||
lu += Vec2f(- offset, offset);
|
|
||||||
rd += Vec2f( offset, - offset);
|
|
||||||
ru += Vec2f( offset, offset);
|
|
||||||
}
|
|
||||||
void expand(const float offset_x, const float offset_y) {
|
|
||||||
ld += Vec2f(- offset_x, - offset_y);
|
|
||||||
lu += Vec2f(- offset_x, offset_y);
|
|
||||||
rd += Vec2f( offset_x, - offset_y);
|
|
||||||
ru += Vec2f( offset_x, offset_y);
|
|
||||||
}
|
|
||||||
Vec2f ld; // left down
|
|
||||||
Vec2f lu; // left upper
|
|
||||||
Vec2f rd; // right lower
|
|
||||||
Vec2f ru; // right upper
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// to store information about tool changes for a given layer
|
// to store information about tool changes for a given layer
|
||||||
struct WipeTowerInfo{
|
struct WipeTowerInfo{
|
||||||
struct ToolChange {
|
struct ToolChange {
|
||||||
|
@ -366,12 +359,6 @@ private:
|
||||||
int first_toolchange_to_nonsoluble(
|
int first_toolchange_to_nonsoluble(
|
||||||
const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const;
|
const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const;
|
||||||
|
|
||||||
|
|
||||||
// Returns gcode for wipe tower brim
|
|
||||||
// sideOnly -- set to false -- experimental, draw brim on sides of wipe tower
|
|
||||||
// offset -- set to 0 -- experimental, offset to replace brim in front / rear of wipe tower
|
|
||||||
ToolChangeResult toolchange_Brim(bool sideOnly = false, float y_offset = 0.f);
|
|
||||||
|
|
||||||
void toolchange_Unload(
|
void toolchange_Unload(
|
||||||
WipeTowerWriter &writer,
|
WipeTowerWriter &writer,
|
||||||
const box_coordinates &cleaning_box,
|
const box_coordinates &cleaning_box,
|
||||||
|
|
|
@ -2013,8 +2013,8 @@ void Print::_make_wipe_tower()
|
||||||
volume_to_wipe += (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id);
|
volume_to_wipe += (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id);
|
||||||
|
|
||||||
// request a toolchange at the wipe tower with at least volume_to_wipe purging amount
|
// request a toolchange at the wipe tower with at least volume_to_wipe purging amount
|
||||||
wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id,
|
wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height,
|
||||||
first_layer && extruder_id == m_wipe_tower_data.tool_ordering.all_extruders().back(), volume_to_wipe);
|
current_extruder_id, extruder_id, volume_to_wipe);
|
||||||
current_extruder_id = extruder_id;
|
current_extruder_id = extruder_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue