Wipe tower: fix the cone in combination with 'no_sparse_layers'

This commit is contained in:
Lukas Matena 2023-03-22 09:45:30 +01:00
parent b20325671a
commit 64cf357907
2 changed files with 12 additions and 2 deletions

View file

@ -1183,7 +1183,9 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
auto supported_rectangle = [this, &writer, spacing](const box_coordinates& wt_box, double feedrate, bool infill_cone) -> Polygon {
const auto [R, support_scale] = get_wipe_tower_cone_base(m_wipe_tower_width, m_wipe_tower_height, m_wipe_tower_depth, m_wipe_tower_cone_angle);
double r = std::tan(Geometry::deg2rad(m_wipe_tower_cone_angle/2.f)) * (m_wipe_tower_height - m_layer_info->z);
double z = m_no_sparse_layers ? (m_current_height + m_layer_info->height) : m_layer_info->z; // the former should actually work in both cases, but let's stay on the safe side (the 2.6.0 is close)
double r = std::tan(Geometry::deg2rad(m_wipe_tower_cone_angle/2.f)) * (m_wipe_tower_height - z);
Vec2f center = (wt_box.lu + wt_box.rd) / 2.;
double w = wt_box.lu.y() - wt_box.ld.y();
enum Type {
@ -1313,9 +1315,11 @@ WipeTower::ToolChangeResult WipeTower::finish_layer()
// 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.
if (! m_no_sparse_layers || toolchanges_on_layer || first_layer)
if (! m_no_sparse_layers || toolchanges_on_layer || first_layer) {
if (m_current_tool < m_used_filament_length.size())
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
m_current_height += m_layer_info->height;
}
return construct_tcr(writer, false, old_tool);
}
@ -1380,6 +1384,7 @@ void WipeTower::plan_tower()
for (auto& layer : m_plan)
layer.depth = 0.f;
m_wipe_tower_height = m_plan.empty() ? 0.f : m_plan.back().z;
m_current_height = 0.f;
for (int layer_index = int(m_plan.size()) - 1; layer_index >= 0; --layer_index)
{
@ -1471,6 +1476,7 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &
}
m_layer_info = m_plan.begin();
m_current_height = 0.f;
// we don't know which extruder to start with - we'll set it according to the first toolchange
for (const auto& layer : m_plan) {

View file

@ -364,6 +364,10 @@ private:
std::vector<WipeTowerInfo> m_plan; // Stores information about all layers and toolchanges for the future wipe tower (filled by plan_toolchange(...))
std::vector<WipeTowerInfo>::iterator m_layer_info = m_plan.end();
// This sums height of all extruded layers, not counting the layers which
// will be later removed when the "no_sparse_layers" is used.
float m_current_height = 0.f;
// Stores information about used filament length per extruder:
std::vector<float> m_used_filament_length;