OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GCode::PlaceholderParserIntegration Struct Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.hpp>

Collaboration diagram for Slic3r::GCode::PlaceholderParserIntegration:

Public Member Functions

void reset ()
void init (const GCodeWriter &config)
void update_from_gcodewriter (const GCodeWriter &writer)
void validate_output_vector_variables ()

Public Attributes

PlaceholderParser parser
PlaceholderParser::ContextData context
std::map< std::string, std::string > failed_templates
DynamicConfig output_config
ConfigOptionFloats * opt_position { nullptr }
ConfigOptionFloat * opt_zhop { nullptr }
ConfigOptionFloats * opt_e_position { nullptr }
ConfigOptionFloats * opt_e_retracted { nullptr }
ConfigOptionFloats * opt_e_restart_extra { nullptr }
ConfigOptionFloats * opt_extruded_volume { nullptr }
ConfigOptionFloats * opt_extruded_weight { nullptr }
ConfigOptionFloat * opt_extruded_volume_total { nullptr }
ConfigOptionFloat * opt_extruded_weight_total { nullptr }
size_t num_extruders
std::vector< double > position
std::vector< double > e_position
std::vector< double > e_retracted
std::vector< double > e_restart_extra

Detailed Description

Member Function Documentation

◆ init()

void Slic3r::GCode::PlaceholderParserIntegration::init ( const GCodeWriter & config)
2180{
2181 this->reset();
2182 const std::vector<Extruder> &extruders = writer.extruders();
2183 if (! extruders.empty()) {
2184 this->num_extruders = extruders.back().id() + 1;
2185 this->e_retracted.assign(MAXIMUM_EXTRUDER_NUMBER, 0);
2189 this->output_config.set_key_value("e_retracted", this->opt_e_retracted);
2190 this->output_config.set_key_value("e_restart_extra", this->opt_e_restart_extra);
2191 if (! writer.config.use_relative_e_distances) {
2194 this->output_config.set_key_value("e_position", opt_e_position);
2195 }
2196 }
2201 this->parser.set("extruded_volume", this->opt_extruded_volume);
2202 this->parser.set("extruded_weight", this->opt_extruded_weight);
2203 this->parser.set("extruded_volume_total", this->opt_extruded_volume_total);
2204 this->parser.set("extruded_weight_total", this->opt_extruded_weight_total);
2205
2206 // Reserve buffer for current position.
2207 this->position.assign(3, 0);
2208 this->opt_position = new ConfigOptionFloats(this->position);
2209 this->output_config.set_key_value("position", this->opt_position);
2210 // Store zhop variable into the parser itself, it is a read-only variable to the script.
2212 this->parser.set("zhop", this->opt_zhop);
2213}
const std::vector< Extruder > & extruders() const
Definition GCodeWriter.hpp:54
GCodeConfig config
Definition GCodeWriter.hpp:28
double get_zhop() const
Definition GCodeWriter.hpp:131
GCodeWriter & writer()
Definition GCode.hpp:287
static constexpr size_t MAXIMUM_EXTRUDER_NUMBER
Definition libslic3r.h:70
zaa_minimize_perimeter_height ConfigOptionFloat
Definition PrintConfig.hpp:1954
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015
PlaceholderParser parser
Definition GCode.hpp:751
ConfigOptionFloats * opt_e_position
Definition GCode.hpp:760
std::vector< double > position
Definition GCode.hpp:769
ConfigOptionFloats * opt_e_restart_extra
Definition GCode.hpp:762
ConfigOptionFloats * opt_position
Definition GCode.hpp:758
std::vector< double > e_position
Definition GCode.hpp:770
std::vector< double > e_retracted
Definition GCode.hpp:771
DynamicConfig output_config
Definition GCode.hpp:757
void reset()
Definition GCode.cpp:2159
size_t num_extruders
Definition GCode.hpp:768
ConfigOptionFloat * opt_extruded_volume_total
Definition GCode.hpp:765
ConfigOptionFloats * opt_extruded_weight
Definition GCode.hpp:764
ConfigOptionFloats * opt_e_retracted
Definition GCode.hpp:761
ConfigOptionFloat * opt_zhop
Definition GCode.hpp:759
ConfigOptionFloat * opt_extruded_weight_total
Definition GCode.hpp:766
std::vector< double > e_restart_extra
Definition GCode.hpp:772
ConfigOptionFloats * opt_extruded_volume
Definition GCode.hpp:763

References Slic3r::ConfigOptionFloat, e_position, e_restart_extra, e_retracted, MAXIMUM_EXTRUDER_NUMBER, num_extruders, opt_e_position, opt_e_restart_extra, opt_e_retracted, opt_extruded_volume, opt_extruded_volume_total, opt_extruded_weight, opt_extruded_weight_total, opt_position, opt_zhop, output_config, parser, position, reset(), and Slic3r::GCode::writer().

Here is the call graph for this function:

◆ reset()

void Slic3r::GCode::PlaceholderParserIntegration::reset ( )
2160{
2161 this->failed_templates.clear();
2162 this->output_config.clear();
2163 this->opt_position = nullptr;
2164 this->opt_zhop = nullptr;
2165 this->opt_e_position = nullptr;
2166 this->opt_e_retracted = nullptr;
2167 this->opt_e_restart_extra = nullptr;
2168 this->opt_extruded_volume = nullptr;
2169 this->opt_extruded_weight = nullptr;
2170 this->opt_extruded_volume_total = nullptr;
2171 this->opt_extruded_weight_total = nullptr;
2172 this->num_extruders = 0;
2173 this->position.clear();
2174 this->e_position.clear();
2175 this->e_retracted.clear();
2176 this->e_restart_extra.clear();
2177}
std::map< std::string, std::string > failed_templates
Definition GCode.hpp:755

References e_position, e_restart_extra, e_retracted, failed_templates, num_extruders, opt_e_position, opt_e_restart_extra, opt_e_retracted, opt_extruded_volume, opt_extruded_volume_total, opt_extruded_weight, opt_extruded_weight_total, opt_position, opt_zhop, output_config, and position.

Referenced by init().

Here is the caller graph for this function:

◆ update_from_gcodewriter()

void Slic3r::GCode::PlaceholderParserIntegration::update_from_gcodewriter ( const GCodeWriter & writer)
2216{
2217 memcpy(this->position.data(), writer.get_position().data(), sizeof(double) * 3);
2218 this->opt_position->values = this->position;
2219 this->opt_zhop->value = writer.get_zhop();
2220
2221 if (this->num_extruders > 0) {
2222 const std::vector<Extruder> &extruders = writer.extruders();
2223 assert(! extruders.empty() && num_extruders == extruders.back().id() + 1);
2224 this->e_retracted.assign(MAXIMUM_EXTRUDER_NUMBER, 0);
2226 this->opt_extruded_volume->values.assign(num_extruders, 0);
2227 this->opt_extruded_weight->values.assign(num_extruders, 0);
2228 double total_volume = 0.;
2229 double total_weight = 0.;
2230 for (const Extruder &e : extruders) {
2231 this->e_retracted[e.id()] = e.retracted();
2232 this->e_restart_extra[e.id()] = e.restart_extra();
2233 double v = e.extruded_volume();
2234 double w = v * e.filament_density() * 0.001;
2235 this->opt_extruded_volume->values[e.id()] = v;
2236 this->opt_extruded_weight->values[e.id()] = w;
2237 total_volume += v;
2238 total_weight += w;
2239 }
2240 opt_extruded_volume_total->value = total_volume;
2241 opt_extruded_weight_total->value = total_weight;
2242 opt_e_retracted->values = this->e_retracted;
2243 opt_e_restart_extra->values = this->e_restart_extra;
2244 if (! writer.config.use_relative_e_distances) {
2245 this->e_position.assign(MAXIMUM_EXTRUDER_NUMBER, 0);
2246 for (const Extruder &e : extruders)
2247 this->e_position[e.id()] = e.position();
2248 this->opt_e_position->values = this->e_position;
2249 }
2250 }
2251}
const Vec3d & get_position() const
Definition GCodeWriter.hpp:128
@ Extruder
Definition DevConfigUtil.h:34

References e_position, e_restart_extra, e_retracted, MAXIMUM_EXTRUDER_NUMBER, num_extruders, opt_e_position, opt_e_restart_extra, opt_e_retracted, opt_extruded_volume, opt_extruded_volume_total, opt_extruded_weight, opt_extruded_weight_total, opt_position, opt_zhop, position, and Slic3r::GCode::writer().

Referenced by Slic3r::GCode::placeholder_parser_process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_output_vector_variables()

void Slic3r::GCode::PlaceholderParserIntegration::validate_output_vector_variables ( )
2255{
2256 if (this->opt_position->values.size() != 3)
2257 throw Slic3r::RuntimeError("\"position\" output variable must not be resized by the script.");
2258 if (this->num_extruders > 0) {
2259 if (this->opt_e_position && this->opt_e_position->values.size() != MAXIMUM_EXTRUDER_NUMBER)
2260 throw Slic3r::RuntimeError("\"e_position\" output variable must not be resized by the script.");
2261 if (this->opt_e_retracted->values.size() != MAXIMUM_EXTRUDER_NUMBER)
2262 throw Slic3r::RuntimeError("\"e_retracted\" output variable must not be resized by the script.");
2263 if (this->opt_e_restart_extra->values.size() != MAXIMUM_EXTRUDER_NUMBER)
2264 throw Slic3r::RuntimeError("\"e_restart_extra\" output variable must not be resized by the script.");
2265 }
2266}

References MAXIMUM_EXTRUDER_NUMBER, num_extruders, opt_e_position, opt_e_restart_extra, opt_e_retracted, and opt_position.

Referenced by Slic3r::GCode::placeholder_parser_process().

Here is the caller graph for this function:

Member Data Documentation

◆ context

PlaceholderParser::ContextData Slic3r::GCode::PlaceholderParserIntegration::context

◆ e_position

std::vector<double> Slic3r::GCode::PlaceholderParserIntegration::e_position

◆ e_restart_extra

std::vector<double> Slic3r::GCode::PlaceholderParserIntegration::e_restart_extra

◆ e_retracted

std::vector<double> Slic3r::GCode::PlaceholderParserIntegration::e_retracted

◆ failed_templates

std::map<std::string, std::string> Slic3r::GCode::PlaceholderParserIntegration::failed_templates

◆ num_extruders

size_t Slic3r::GCode::PlaceholderParserIntegration::num_extruders

◆ opt_e_position

ConfigOptionFloats* Slic3r::GCode::PlaceholderParserIntegration::opt_e_position { nullptr }

◆ opt_e_restart_extra

ConfigOptionFloats* Slic3r::GCode::PlaceholderParserIntegration::opt_e_restart_extra { nullptr }

◆ opt_e_retracted

ConfigOptionFloats* Slic3r::GCode::PlaceholderParserIntegration::opt_e_retracted { nullptr }

◆ opt_extruded_volume

ConfigOptionFloats* Slic3r::GCode::PlaceholderParserIntegration::opt_extruded_volume { nullptr }
763{ nullptr };

Referenced by init(), reset(), and update_from_gcodewriter().

◆ opt_extruded_volume_total

ConfigOptionFloat* Slic3r::GCode::PlaceholderParserIntegration::opt_extruded_volume_total { nullptr }
765{ nullptr };

Referenced by init(), reset(), and update_from_gcodewriter().

◆ opt_extruded_weight

ConfigOptionFloats* Slic3r::GCode::PlaceholderParserIntegration::opt_extruded_weight { nullptr }
764{ nullptr };

Referenced by init(), reset(), and update_from_gcodewriter().

◆ opt_extruded_weight_total

ConfigOptionFloat* Slic3r::GCode::PlaceholderParserIntegration::opt_extruded_weight_total { nullptr }
766{ nullptr };

Referenced by init(), reset(), and update_from_gcodewriter().

◆ opt_position

ConfigOptionFloats* Slic3r::GCode::PlaceholderParserIntegration::opt_position { nullptr }

◆ opt_zhop

ConfigOptionFloat* Slic3r::GCode::PlaceholderParserIntegration::opt_zhop { nullptr }
759{ nullptr };

Referenced by init(), reset(), and update_from_gcodewriter().

◆ output_config

DynamicConfig Slic3r::GCode::PlaceholderParserIntegration::output_config

◆ parser

PlaceholderParser Slic3r::GCode::PlaceholderParserIntegration::parser

◆ position

std::vector<double> Slic3r::GCode::PlaceholderParserIntegration::position

The documentation for this struct was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.cpp