Wipe tower: changed the way how initial wipe tower preview depth is calculated

This commit is contained in:
Lukas Matena 2023-03-17 13:49:35 +01:00 committed by SoftFever
parent cd3bbdb5f5
commit ee4705d6b7
2 changed files with 28 additions and 0 deletions

View file

@ -1328,6 +1328,33 @@ WipeTower::ToolChangeResult WipeTower::finish_layer(bool extrude_perimeter, bool
return construct_tcr(writer, false, old_tool, true, 0.f);
}
// Static method to extract wipe_volumes[from][to] from the configuration.
std::vector<std::vector<float>> WipeTower::extract_wipe_volumes(const PrintConfig& config)
{
// Get wiping matrix to get number of extruders and convert vector<double> to vector<float>:
std::vector<float> wiping_matrix(cast<float>(config.flush_volumes_matrix.values));
auto scale = config.flush_multiplier;
// Orca todo: currently we only/always support SEMM.
// The values shall only be used when SEMM is enabled. The purging for other printers
// is determined by filament_minimal_purge_on_wipe_tower.
// if (! config.single_extruder_multi_material.value)
// std::fill(wiping_matrix.begin(), wiping_matrix.end(), 0.f);
// Extract purging volumes for each extruder pair:
std::vector<std::vector<float>> wipe_volumes;
const unsigned int number_of_extruders = (unsigned int)(sqrt(wiping_matrix.size())+EPSILON);
for (unsigned int i = 0; i<number_of_extruders; ++i)
wipe_volumes.push_back(std::vector<float>(wiping_matrix.begin()+i*number_of_extruders, wiping_matrix.begin()+(i+1)*number_of_extruders));
// Also include filament_minimal_purge_on_wipe_tower. This is needed for the preview.
for (unsigned int i = 0; i<number_of_extruders; ++i)
for (unsigned int j = 0; j<number_of_extruders; ++j)
wipe_volumes[i][j] = std::max<float>(wipe_volumes[i][j] * scale, config.filament_minimal_purge_on_wipe_tower.get_at(j));
return wipe_volumes;
}
// 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, float wipe_volume, float purge_volume)

View file

@ -25,6 +25,7 @@ public:
// WipeTower height to minimum depth map
static const std::map<float, float> min_depth_per_height;
static std::vector<std::vector<float>> extract_wipe_volumes(const PrintConfig& config);
struct Extrusion
{