mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 23:52:02 +08:00
Fixed placeholders extruded_volume and similar: wipe tower was not included
This commit is contained in:
parent
642535eecb
commit
601d61ca86
@ -236,7 +236,7 @@ void GCodeGenerator::PlaceholderParserIntegration::init(const GCodeWriter &write
|
|||||||
this->parser.set("zhop", this->opt_zhop);
|
this->parser.set("zhop", this->opt_zhop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeGenerator::PlaceholderParserIntegration::update_from_gcodewriter(const GCodeWriter &writer)
|
void GCodeGenerator::PlaceholderParserIntegration::update_from_gcodewriter(const GCodeWriter &writer, const WipeTowerData& wipe_tower_data)
|
||||||
{
|
{
|
||||||
memcpy(this->position.data(), writer.get_position().data(), sizeof(double) * 3);
|
memcpy(this->position.data(), writer.get_position().data(), sizeof(double) * 3);
|
||||||
this->opt_position->values = this->position;
|
this->opt_position->values = this->position;
|
||||||
@ -253,7 +253,19 @@ void GCodeGenerator::PlaceholderParserIntegration::update_from_gcodewriter(const
|
|||||||
for (const Extruder &e : extruders) {
|
for (const Extruder &e : extruders) {
|
||||||
this->e_retracted[e.id()] = e.retracted();
|
this->e_retracted[e.id()] = e.retracted();
|
||||||
this->e_restart_extra[e.id()] = e.restart_extra();
|
this->e_restart_extra[e.id()] = e.restart_extra();
|
||||||
double v = e.extruded_volume();
|
|
||||||
|
// Wipe tower filament consumption has to be added separately, because that gcode is not generated by GCodeWriter.
|
||||||
|
double wt_vol = 0.;
|
||||||
|
const std::vector<std::pair<float, std::vector<float>>>& wtuf = wipe_tower_data.used_filament_until_layer;
|
||||||
|
if (!wtuf.empty()) {
|
||||||
|
auto it = std::lower_bound(wtuf.begin(), wtuf.end(), writer.get_position().z(),
|
||||||
|
[](const auto& a, const float& val) { return a.first < val; });
|
||||||
|
if (it == wtuf.end())
|
||||||
|
it = wtuf.end() - 1;
|
||||||
|
wt_vol = it->second[e.id()] * e.filament_crossection();
|
||||||
|
}
|
||||||
|
|
||||||
|
double v = e.extruded_volume() + wt_vol;
|
||||||
double w = v * e.filament_density() * 0.001;
|
double w = v * e.filament_density() * 0.001;
|
||||||
this->opt_extruded_volume->values[e.id()] = v;
|
this->opt_extruded_volume->values[e.id()] = v;
|
||||||
this->opt_extruded_weight->values[e.id()] = w;
|
this->opt_extruded_weight->values[e.id()] = w;
|
||||||
@ -1657,7 +1669,7 @@ std::string GCodeGenerator::placeholder_parser_process(
|
|||||||
|
|
||||||
PlaceholderParserIntegration &ppi = m_placeholder_parser_integration;
|
PlaceholderParserIntegration &ppi = m_placeholder_parser_integration;
|
||||||
try {
|
try {
|
||||||
ppi.update_from_gcodewriter(m_writer);
|
ppi.update_from_gcodewriter(m_writer, m_print->wipe_tower_data());
|
||||||
std::string output = ppi.parser.process(templ, current_extruder_id, config_override, &ppi.output_config, &ppi.context);
|
std::string output = ppi.parser.process(templ, current_extruder_id, config_override, &ppi.output_config, &ppi.context);
|
||||||
ppi.validate_output_vector_variables();
|
ppi.validate_output_vector_variables();
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ namespace Slic3r {
|
|||||||
|
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
class GCodeGenerator;
|
class GCodeGenerator;
|
||||||
|
struct WipeTowerData;
|
||||||
|
|
||||||
namespace { struct Item; }
|
namespace { struct Item; }
|
||||||
struct PrintInstance;
|
struct PrintInstance;
|
||||||
@ -356,7 +357,7 @@ private:
|
|||||||
struct PlaceholderParserIntegration {
|
struct PlaceholderParserIntegration {
|
||||||
void reset();
|
void reset();
|
||||||
void init(const GCodeWriter &config);
|
void init(const GCodeWriter &config);
|
||||||
void update_from_gcodewriter(const GCodeWriter &writer);
|
void update_from_gcodewriter(const GCodeWriter &writer, const WipeTowerData& wipe_tower_data);
|
||||||
void validate_output_vector_variables();
|
void validate_output_vector_variables();
|
||||||
|
|
||||||
PlaceholderParser parser;
|
PlaceholderParser parser;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user