Fixing conflicts part 4:

See previous commit. This one applies changes from master_250
to the files mentioned
This commit is contained in:
Lukas Matena 2022-06-29 16:12:52 +02:00
parent d662bf2a18
commit 6c0db58628
10 changed files with 88 additions and 54 deletions
src/libslic3r/GCode

View file

@ -679,13 +679,30 @@ void GCodeProcessor::UsedFilaments::reset()
role_cache = 0.0;
filaments_per_role.clear();
extruder_retracted_volume.clear();
}
void GCodeProcessor::UsedFilaments::increase_caches(double extruded_volume)
void GCodeProcessor::UsedFilaments::increase_caches(double extruded_volume, unsigned char extruder_id, double parking_volume, double extra_loading_volume)
{
color_change_cache += extruded_volume;
tool_change_cache += extruded_volume;
role_cache += extruded_volume;
if (extruder_id >= extruder_retracted_volume.size())
extruder_retracted_volume.resize(extruder_id + 1, parking_volume);
if (recent_toolchange) {
extruded_volume -= extra_loading_volume;
recent_toolchange = false;
}
extruder_retracted_volume[extruder_id] -= extruded_volume;
if (extruder_retracted_volume[extruder_id] < 0.) {
extruded_volume = - extruder_retracted_volume[extruder_id];
extruder_retracted_volume[extruder_id] = 0.;
color_change_cache += extruded_volume;
tool_change_cache += extruded_volume;
role_cache += extruded_volume;
}
}
void GCodeProcessor::UsedFilaments::process_color_change_cache()
@ -696,19 +713,16 @@ void GCodeProcessor::UsedFilaments::process_color_change_cache()
}
}
void GCodeProcessor::UsedFilaments::process_extruder_cache(GCodeProcessor* processor)
{
size_t active_extruder_id = processor->m_extruder_id;
void GCodeProcessor::UsedFilaments::process_extruder_cache(unsigned char extruder_id)
{
if (tool_change_cache != 0.0) {
if (volumes_per_extruder.find(active_extruder_id) != volumes_per_extruder.end())
volumes_per_extruder[active_extruder_id] += tool_change_cache;
else
volumes_per_extruder[active_extruder_id] = tool_change_cache;
tool_change_cache = 0.0;
}
volumes_per_extruder[extruder_id] += tool_change_cache;
tool_change_cache = 0.0;
}
recent_toolchange = true;
}
void GCodeProcessor::UsedFilaments::process_role_cache(GCodeProcessor* processor)
void GCodeProcessor::UsedFilaments::process_role_cache(const GCodeProcessor* processor)
{
if (role_cache != 0.0) {
std::pair<double, double> filament = { 0.0f, 0.0f };
@ -728,10 +742,10 @@ void GCodeProcessor::UsedFilaments::process_role_cache(GCodeProcessor* processor
}
}
void GCodeProcessor::UsedFilaments::process_caches(GCodeProcessor* processor)
void GCodeProcessor::UsedFilaments::process_caches(const GCodeProcessor* processor)
{
process_color_change_cache();
process_extruder_cache(processor);
process_extruder_cache(processor->m_extruder_id);
process_role_cache(processor);
}
@ -901,7 +915,14 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
m_time_processor.filament_unload_times[i] = static_cast<float>(config.filament_unload_time.values[i]);
}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
// With MM setups like Prusa MMU2, the filaments may be expected to be parked at the beginning.
// Remember the parking position so the initial load is not included in filament estimate.
if (config.single_extruder_multi_material && extruders_count > 1 && config.wipe_tower) {
m_parking_position = float(config.parking_pos_retraction.value);
m_extra_loading_move = float(config.extra_loading_move);
}
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i);
m_time_processor.machines[i].max_acceleration = max_acceleration;
m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION;
@ -1242,6 +1263,8 @@ void GCodeProcessor::reset()
m_extruder_temps[i] = 0.0f;
}
m_parking_position = 0.f;
m_extra_loading_move = 0.f;
m_extruded_last_z = 0.0f;
m_first_layer_height = 0.0f;
m_g1_line_id = 0;
@ -2550,27 +2573,26 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
if (line.has_f())
m_feedrate = m_feed_multiply.current * line.f() * MMMIN_TO_MMSEC;
// calculates movement deltas
float max_abs_delta = 0.0f;
AxisCoords delta_pos;
for (unsigned char a = X; a <= E; ++a) {
delta_pos[a] = m_end_position[a] - m_start_position[a];
max_abs_delta = std::max<float>(max_abs_delta, std::abs(delta_pos[a]));
}
// calculates movement deltas
AxisCoords delta_pos;
for (unsigned char a = X; a <= E; ++a)
delta_pos[a] = m_end_position[a] - m_start_position[a];
if (std::all_of(delta_pos.begin(), delta_pos.end(), [](double d) { return d == 0.; }))
return;
const float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
// no displacement, return
if (max_abs_delta == 0.0f)
return;
if (volume_extruded_filament != 0.)
m_used_filaments.increase_caches(volume_extruded_filament,
this->m_extruder_id, area_filament_cross_section * this->m_parking_position,
area_filament_cross_section * this->m_extra_loading_move);
const EMoveType type = move_type(delta_pos);
if (type == EMoveType::Extrude) {
const float delta_xyz = std::sqrt(sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]));
const float volume_extruded_filament = area_filament_cross_section * delta_pos[E];
const float area_toolpath_cross_section = volume_extruded_filament / delta_xyz;
// save extruded volume to the cache
m_used_filaments.increase_caches(volume_extruded_filament);
// volume extruded filament / tool displacement = area toolpath cross section
m_mm3_per_mm = area_toolpath_cross_section;
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
@ -4090,7 +4112,7 @@ void GCodeProcessor::process_filaments(CustomGCode::Type code)
m_used_filaments.process_color_change_cache();
if (code == CustomGCode::ToolChange)
m_used_filaments.process_extruder_cache(this);
m_used_filaments.process_extruder_cache(this->m_extruder_id);
}
void GCodeProcessor::simulate_st_synchronize(float additional_time)