Skip to content

Commit

Permalink
Wipe tower: don't do sparse infill when there is a soluble filament a…
Browse files Browse the repository at this point in the history
…bove it
  • Loading branch information
lukasmatena committed Apr 5, 2021
1 parent dd4b26b commit 97c4c02
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
53 changes: 41 additions & 12 deletions src/libslic3r/GCode/WipeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,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);

Expand Down Expand Up @@ -1192,19 +1193,47 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
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);

const int n = 1+int((right-left)/m_bridging);
const float dx = (right-left)/n;
for (int i=1;i<=n;++i) {
float x=left+dx*i;
writer.travel(x,writer.y());
writer.extrude(x,i%2 ? fill_box.rd.y() : fill_box.ru.y());
writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f));

// 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;
});

if (solid_infill) {
const float sparse_factor = 1.5f; // 1=solid, 2=every other line, etc.
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, 2900 * speed_factor)
.extrude(i%2 ? left : right, y);
y = y + spacing;
}
writer.extrude(writer.x(), fill_box.lu.y())
.add_wipe_point(Vec2f(writer.x(), writer.y()))
.add_wipe_point(Vec2f(i%2 ? left : right, writer.y()));
} else {
// Extrude an inverse U at the left of the region.
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 float dx = (right-left)/n;
for (int i=1;i<=n;++i) {
float x=left+dx*i;
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()));
}
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()))
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/GCode/WipeTower.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class WipeTower

struct FilamentParameters {
std::string material = "PLA";
bool is_soluble = false;
int temperature = 0;
int first_layer_temperature = 0;
float loading_speed = 0.f;
Expand Down

0 comments on commit 97c4c02

Please sign in to comment.