OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::DoExport Namespace Reference

Functions

static void update_print_estimated_stats (const GCodeProcessor &processor, const std::vector< Extruder > &extruders, PrintStatistics &print_statistics, const PrintConfig &config)
static std::vector< std::pair< std::string, std::string > > validate_custom_gcode (const Print &print)
static void init_gcode_processor (const PrintConfig &config, GCodeProcessor &processor, const std::shared_ptr< MultiNozzleUtils::NozzleGroupResultBase > &nozzle_group_result=nullptr)
static void init_ooze_prevention (const Print &print, OozePrevention &ooze_prevention)
static int total_toolchanges_from_ordering (const ToolOrdering &tool_ordering)
static int resolve_total_toolchanges (const WipeTowerData &wipe_tower_data, const ToolOrdering &tool_ordering)
static std::string update_print_stats_and_format_filament_stats (const bool has_wipe_tower, const WipeTowerData &wipe_tower_data, const std::vector< Extruder > &extruders, PrintStatistics &print_statistics, const ToolOrdering &tool_ordering)

Function Documentation

◆ init_gcode_processor()

void Slic3r::DoExport::init_gcode_processor ( const PrintConfig & config,
GCodeProcessor & processor,
const std::shared_ptr< MultiNozzleUtils::NozzleGroupResultBase > & nozzle_group_result = nullptr )
static
3102 {
3103 processor.reset();
3104 // Slot-resolution context for the streaming replay (reset() just cleared it). This is NOT
3105 // the post-stream result-field handover at the end of do_export, which gates the richer
3106 // change-time model and must stay after the stream.
3107 processor.initialize_from_context(nozzle_group_result);
3108 processor.initialize_result_moves();
3109 processor.apply_config(config);
3110 processor.configure_exclusion_volume_path_check(config);
3111 }
void initialize_result_moves()
Definition GCodeProcessor.hpp:1445
void initialize_from_context(const std::shared_ptr< MultiNozzleUtils::NozzleGroupResultBase > &nozzle_group_result)
Definition GCodeProcessor.hpp:1422
void apply_config(const PrintConfig &config)
Definition GCodeProcessor.cpp:3113
void reset()
Definition GCodeProcessor.cpp:3702
void configure_exclusion_volume_path_check(const PrintConfig &config)
Definition GCodeProcessor.cpp:3932

References Slic3r::GCodeProcessor::apply_config(), Slic3r::GCodeProcessor::configure_exclusion_volume_path_check(), init_gcode_processor(), Slic3r::GCodeProcessor::initialize_from_context(), Slic3r::GCodeProcessor::initialize_result_moves(), and Slic3r::GCodeProcessor::reset().

Referenced by Slic3r::GCode::_do_export(), and init_gcode_processor().

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

◆ init_ooze_prevention()

void Slic3r::DoExport::init_ooze_prevention ( const Print & print,
OozePrevention & ooze_prevention )
static
3174 {
3175 ooze_prevention.enable = print.config().ooze_prevention.value && ! print.config().single_extruder_multi_material;
3176 }
const PrintConfig & config() const
Definition Print.hpp:1131
zaa_minimize_perimeter_height ooze_prevention((ConfigOptionString, filename_format))((ConfigOptionStrings

References Slic3r::Print::config(), init_ooze_prevention(), and Slic3r::ooze_prevention().

Referenced by Slic3r::GCode::_do_export(), and init_ooze_prevention().

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

◆ resolve_total_toolchanges()

int Slic3r::DoExport::resolve_total_toolchanges ( const WipeTowerData & wipe_tower_data,
const ToolOrdering & tool_ordering )
static
3198 {
3199 int changes = wipe_tower_data.number_of_toolchanges;
3200 if (changes < 0)
3201 changes = total_toolchanges_from_ordering(tool_ordering);
3202 return std::max(0, changes);
3203 }
static int total_toolchanges_from_ordering(const ToolOrdering &tool_ordering)
Definition GCode.cpp:3182
int number_of_toolchanges
Definition Print.hpp:917

References Slic3r::WipeTowerData::number_of_toolchanges, resolve_total_toolchanges(), and total_toolchanges_from_ordering().

Referenced by Slic3r::GCode::_do_export(), resolve_total_toolchanges(), and update_print_stats_and_format_filament_stats().

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

◆ total_toolchanges_from_ordering()

int Slic3r::DoExport::total_toolchanges_from_ordering ( const ToolOrdering & tool_ordering)
static
3183 {
3184 int changes = 0;
3185 int last = -1;
3186 for (const LayerTools &lt : tool_ordering)
3187 for (unsigned int extruder : lt.extruders) {
3188 if (last >= 0 && int(extruder) != last)
3189 ++ changes;
3190 last = int(extruder);
3191 }
3192 return changes;
3193 }
Definition ToolOrdering.hpp:152

References total_toolchanges_from_ordering().

Referenced by resolve_total_toolchanges(), and total_toolchanges_from_ordering().

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

◆ update_print_estimated_stats()

void Slic3r::DoExport::update_print_estimated_stats ( const GCodeProcessor & processor,
const std::vector< Extruder > & extruders,
PrintStatistics & print_statistics,
const PrintConfig & config )
static
2537 {
2538 const GCodeProcessorResult& result = processor.get_result();
2539 double normal_print_time = result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].time;
2540 print_statistics.estimated_normal_print_time = get_time_dhms(normal_print_time);
2541 print_statistics.estimated_silent_print_time = processor.is_stealth_time_estimator_enabled() ?
2542 get_time_dhms(result.print_statistics.modes[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].time) : "N/A";
2543
2544 // update filament statictics
2545 double total_extruded_volume = 0.0;
2546 double total_used_filament = 0.0;
2547 double total_weight = 0.0;
2548 double total_cost = 0.0;
2549
2550 for (auto volume : result.print_statistics.total_volumes_per_extruder) {
2551 total_extruded_volume += volume.second;
2552
2553 size_t extruder_id = volume.first;
2554 auto extruder = std::find_if(extruders.begin(), extruders.end(), [extruder_id](const Extruder& extr) {return extr.id() == extruder_id; });
2555 if (extruder == extruders.end())
2556 continue;
2557
2558 double s = PI * sqr(0.5* extruder->filament_diameter());
2559 double weight = volume.second * extruder->filament_density() * 0.001;
2560 total_used_filament += volume.second/s;
2561 total_weight += weight;
2562 total_cost += weight * extruder->filament_cost() * 0.001;
2563 }
2564
2565 total_cost += config.time_cost.getFloat() * (normal_print_time/3600.0);
2566
2567 print_statistics.total_extruded_volume = total_extruded_volume;
2568 print_statistics.total_used_filament = total_used_filament;
2569 print_statistics.total_weight = total_weight;
2570 print_statistics.total_cost = total_cost;
2571
2573 }
Definition Extruder.hpp:12
const GCodeProcessorResult & get_result() const
Definition GCodeProcessor.hpp:1434
bool is_stealth_time_estimator_enabled() const
Definition GCodeProcessor.hpp:1428
static constexpr double PI
Definition libslic3r.h:81
constexpr T sqr(T x)
Definition libslic3r.h:301
std::string get_time_dhms(float time_in_secs)
Definition Utils.hpp:609
Definition GCodeProcessor.hpp:200
PrintEstimatedStatistics print_statistics
Definition GCodeProcessor.hpp:373
std::map< size_t, double > total_volumes_per_extruder
Definition GCodeProcessor.hpp:112
@ Stealth
Definition GCodeProcessor.hpp:90
@ Normal
Definition GCodeProcessor.hpp:89
std::map< size_t, double > model_volumes_per_extruder
Definition GCodeProcessor.hpp:109
std::array< Mode, static_cast< size_t >(ETimeMode::Count)> modes
Definition GCodeProcessor.hpp:117
std::string estimated_normal_print_time
Definition Print.hpp:957
std::map< size_t, double > filament_stats
Definition Print.hpp:968
double total_used_filament
Definition Print.hpp:959
std::string estimated_silent_print_time
Definition Print.hpp:958
double total_extruded_volume
Definition Print.hpp:960
double total_cost
Definition Print.hpp:961
double total_weight
Definition Print.hpp:963

References Slic3r::PrintStatistics::estimated_normal_print_time, Slic3r::PrintStatistics::estimated_silent_print_time, Slic3r::PrintStatistics::filament_stats, Slic3r::GCodeProcessor::get_result(), Slic3r::get_time_dhms(), Slic3r::GCodeProcessor::is_stealth_time_estimator_enabled(), Slic3r::PrintEstimatedStatistics::model_volumes_per_extruder, Slic3r::PrintEstimatedStatistics::modes, Slic3r::PrintEstimatedStatistics::Normal, PI, Slic3r::GCodeProcessorResult::print_statistics, Slic3r::sqr(), Slic3r::PrintEstimatedStatistics::Stealth, Slic3r::PrintStatistics::total_cost, Slic3r::PrintStatistics::total_extruded_volume, Slic3r::PrintStatistics::total_used_filament, Slic3r::PrintEstimatedStatistics::total_volumes_per_extruder, Slic3r::PrintStatistics::total_weight, and update_print_estimated_stats().

Referenced by Slic3r::GCode::do_export(), and update_print_estimated_stats().

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

◆ update_print_stats_and_format_filament_stats()

std::string Slic3r::DoExport::update_print_stats_and_format_filament_stats ( const bool has_wipe_tower,
const WipeTowerData & wipe_tower_data,
const std::vector< Extruder > & extruders,
PrintStatistics & print_statistics,
const ToolOrdering & tool_ordering )
static
3212 {
3213 std::string filament_stats_string_out;
3214
3215 print_statistics.clear();
3216 print_statistics.total_toolchanges = resolve_total_toolchanges(wipe_tower_data, tool_ordering);
3217 if (! extruders.empty()) {
3218 std::pair<std::string, unsigned int> out_filament_used_mm ("; filament used [mm] = ", 0);
3219 std::pair<std::string, unsigned int> out_filament_used_cm3("; filament used [cm3] = ", 0);
3220 std::pair<std::string, unsigned int> out_filament_used_g ("; filament used [g] = ", 0);
3221 std::pair<std::string, unsigned int> out_filament_cost ("; filament cost = ", 0);
3222 for (const Extruder &extruder : extruders) {
3223 double used_filament = extruder.used_filament() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] : 0.f);
3224 double extruded_volume = extruder.extruded_volume() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] * 2.4052f : 0.f); // assumes 1.75mm filament diameter
3225 double filament_weight = extruded_volume * extruder.filament_density() * 0.001;
3226 double filament_cost = filament_weight * extruder.filament_cost() * 0.001;
3227 auto append = [&extruder](std::pair<std::string, unsigned int> &dst, const char *tmpl, double value) {
3229 while (dst.second < extruder.id()) {
3230 // Fill in the non-printing extruders with zeros.
3231 dst.first += (dst.second > 0) ? ", 0" : "0";
3232 ++ dst.second;
3233 }
3234 if (dst.second > 0)
3235 dst.first += ", ";
3236 char buf[64];
3237 sprintf(buf, tmpl, value);
3238 dst.first += buf;
3239 ++ dst.second;
3240 };
3241 append(out_filament_used_mm, "%.2lf", used_filament);
3242 append(out_filament_used_cm3, "%.2lf", extruded_volume * 0.001);
3243 if (filament_weight > 0.) {
3244 print_statistics.total_weight = print_statistics.total_weight + filament_weight;
3245 append(out_filament_used_g, "%.2lf", filament_weight);
3246 if (filament_cost > 0.) {
3247 print_statistics.total_cost = print_statistics.total_cost + filament_cost;
3248 append(out_filament_cost, "%.2lf", filament_cost);
3249 }
3250 }
3251 print_statistics.total_used_filament += used_filament;
3252 print_statistics.total_extruded_volume += extruded_volume;
3253 print_statistics.total_wipe_tower_filament += has_wipe_tower ? used_filament - extruder.used_filament() : 0.;
3254 print_statistics.total_wipe_tower_cost += has_wipe_tower ? (extruded_volume - extruder.extruded_volume())* extruder.filament_density() * 0.001 * extruder.filament_cost() * 0.001 : 0.;
3255 }
3256 filament_stats_string_out += out_filament_used_mm.first;
3257 filament_stats_string_out += "\n" + out_filament_used_cm3.first;
3258 if (out_filament_used_g.second)
3259 filament_stats_string_out += "\n" + out_filament_used_g.first;
3260 if (out_filament_cost.second)
3261 filament_stats_string_out += "\n" + out_filament_cost.first;
3262 filament_stats_string_out += "\n";
3263 }
3264 return filament_stats_string_out;
3265 }
static int resolve_total_toolchanges(const WipeTowerData &wipe_tower_data, const ToolOrdering &tool_ordering)
Definition GCode.cpp:3197
bool is_decimal_separator_point()
Definition LocalesUtils.cpp:78
void append(std::vector< T, Alloc > &dest, const std::vector< T, Alloc2 > &src)
Definition libslic3r.h:157
zaa_minimize_perimeter_height filament_cost((ConfigOptionStrings, default_filament_colour))((ConfigOptionInts
double total_wipe_tower_cost
Definition Print.hpp:964
double total_wipe_tower_filament
Definition Print.hpp:965
int total_toolchanges
Definition Print.hpp:962
void clear()
Definition Print.hpp:977
std::vector< float > used_filament
Definition Print.hpp:916

References Slic3r::append(), Slic3r::PrintStatistics::clear(), Slic3r::filament_cost(), Slic3r::is_decimal_separator_point(), resolve_total_toolchanges(), Slic3r::PrintStatistics::total_cost, Slic3r::PrintStatistics::total_extruded_volume, Slic3r::PrintStatistics::total_toolchanges, Slic3r::PrintStatistics::total_used_filament, Slic3r::PrintStatistics::total_weight, Slic3r::PrintStatistics::total_wipe_tower_cost, Slic3r::PrintStatistics::total_wipe_tower_filament, update_print_stats_and_format_filament_stats(), and Slic3r::WipeTowerData::used_filament.

Referenced by Slic3r::GCode::_do_export(), and update_print_stats_and_format_filament_stats().

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

◆ validate_custom_gcode()

std::vector< std::pair< std::string, std::string > > Slic3r::DoExport::validate_custom_gcode ( const Print & print)
static
2581 {
2582 static const unsigned int MAX_TAGS_COUNT = 5;
2583 std::vector<std::pair<std::string, std::string>> ret;
2584
2585 auto check = [&ret, is_bbl_printer = print.is_BBL_printer()](const std::string& source, const std::string& gcode) {
2586 std::vector<std::string> tags;
2587 if (GCodeProcessor::contains_reserved_tags(gcode, MAX_TAGS_COUNT, tags, is_bbl_printer)) {
2588 if (!tags.empty()) {
2589 size_t i = 0;
2590 while (ret.size() < MAX_TAGS_COUNT && i < tags.size()) {
2591 ret.push_back({ source, tags[i] });
2592 ++i;
2593 }
2594 }
2595 }
2596 };
2597
2598 const GCodeConfig& config = print.config();
2599 check(_(L("Machine start G-code")), config.machine_start_gcode.value);
2600 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Machine end G-code")), config.machine_end_gcode.value);
2601 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Before layer change G-code")), config.before_layer_change_gcode.value);
2602 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Layer change G-code")), config.layer_change_gcode.value);
2603 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Timelapse G-code")), config.time_lapse_gcode.value);
2604 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Timelapse G-code")), config.wrapping_detection_gcode.value);
2605 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Change filament G-code")), config.change_filament_gcode.value);
2606 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Printing by object G-code")), config.printing_by_object_gcode.value);
2607 //if (ret.size() < MAX_TAGS_COUNT) check(_(L("Color Change G-code")), config.color_change_gcode.value);
2608 //Orca
2609 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Change extrusion role G-code")), config.change_extrusion_role_gcode.value);
2610 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Process change extrusion role G-code")), config.process_change_extrusion_role_gcode.value);
2611 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Pause G-code")), config.machine_pause_gcode.value);
2612 if (ret.size() < MAX_TAGS_COUNT) check(_(L("Template Custom G-code")), config.template_custom_gcode.value);
2613 if (ret.size() < MAX_TAGS_COUNT) {
2614 for (const std::string& value : config.filament_start_gcode.values) {
2615 check(_(L("Filament start G-code")), value);
2616 if (ret.size() == MAX_TAGS_COUNT)
2617 break;
2618 }
2619 }
2620 if (ret.size() < MAX_TAGS_COUNT) {
2621 for (const std::string& value : config.filament_end_gcode.values) {
2622 check(_(L("Filament end G-code")), value);
2623 if (ret.size() == MAX_TAGS_COUNT)
2624 break;
2625 }
2626 }
2627 if (ret.size() < MAX_TAGS_COUNT) {
2628 for (const std::string& value : config.filament_change_extrusion_role_gcode.values) {
2629 check(_(L("Filament change extrusion role G-code")), value);
2630 if (ret.size() == MAX_TAGS_COUNT)
2631 break;
2632 }
2633 }
2634 //BBS: no custom_gcode_per_print_z, don't need to check
2635 //if (ret.size() < MAX_TAGS_COUNT) {
2636 // const CustomGCode::Info& custom_gcode_per_print_z = print.model().custom_gcode_per_print_z;
2637 // for (const auto& gcode : custom_gcode_per_print_z.gcodes) {
2638 // check(_(L("Custom G-code")), gcode.extra);
2639 // if (ret.size() == MAX_TAGS_COUNT)
2640 // break;
2641 // }
2642 //}
2643
2644 return ret;
2645 }
#define _(s)
Definition 3mf.cpp:306
#define L(s)
Definition ExtrusionEntity.cpp:25
static bool contains_reserved_tags(const std::string &gcode, unsigned int max_count, std::vector< std::string > &found_tag, bool is_bbl_printer)
Definition GCodeProcessor.cpp:2789
bool & is_BBL_printer()
Definition Print.hpp:1341
zaa_minimize_perimeter_height GCodeConfig
Definition PrintConfig.hpp:1951
bool check(ModelVolumeType volume_type)
Definition GLGizmoEmboss.cpp:515

References _, Slic3r::Print::config(), Slic3r::GCodeProcessor::contains_reserved_tags(), Slic3r::GCodeConfig, Slic3r::Print::is_BBL_printer(), L, and validate_custom_gcode().

Referenced by Slic3r::GCode::do_export(), and validate_custom_gcode().

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