OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SmallAreaInfillFlowCompensator Class Reference

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

Collaboration diagram for Slic3r::SmallAreaInfillFlowCompensator:

Public Member Functions

 SmallAreaInfillFlowCompensator ()=delete
 SmallAreaInfillFlowCompensator (const Slic3r::GCodeConfig &config)
 ~SmallAreaInfillFlowCompensator ()
double modify_flow (const double line_length, const double dE, const ExtrusionRole role)

Private Member Functions

double flow_comp_model (const double line_length)
double max_modified_length ()

Private Attributes

std::vector< double > eLengths
std::vector< double > flowComps
std::unique_ptr< PchipInterpolatorHelper > flowModel

Detailed Description

Constructor & Destructor Documentation

◆ SmallAreaInfillFlowCompensator() [1/2]

Slic3r::SmallAreaInfillFlowCompensator::SmallAreaInfillFlowCompensator ( )
delete

References Slic3r::GCodeConfig.

◆ SmallAreaInfillFlowCompensator() [2/2]

Slic3r::SmallAreaInfillFlowCompensator::SmallAreaInfillFlowCompensator ( const Slic3r::GCodeConfig & config)
explicit
40{
41 try {
42 for (auto& line : config.small_area_infill_flow_compensation_model.values) {
43 std::istringstream iss(line);
44 std::string value_str;
45 double eLength = 0.0;
46
47 if (std::getline(iss, value_str, ',')) {
48 try {
49 // Trim leading and trailing whitespace
50 value_str = std::regex_replace(value_str, std::regex("^\\s+|\\s+$"), "");
51 if (value_str.empty()) {
52 continue;
53 }
54 eLength = std::stod(value_str);
55 if (std::getline(iss, value_str, ',')) {
56 eLengths.push_back(eLength);
57 flowComps.push_back(std::stod(value_str));
58 }
59 } catch (...) {
60 // TRN %1% is the line of the model that could not be parsed.
61 throw Slic3r::InvalidArgument(Slic3r::format(_u8L("Small Area Flow Compensation: Error parsing data point in small area infill compensation model: %1%"), line) + "\n");
62 }
63 }
64 }
65
66 for (size_t i = 0; i < eLengths.size(); i++) {
67 if (i == 0) {
68 if (!nearly_equal(eLengths[i], 0.0)) {
69 throw Slic3r::InvalidArgument(_u8L("Small Area Flow Compensation: First extrusion length for small area infill compensation model must be 0"));
70 }
71 } else {
72 if (nearly_equal(eLengths[i], 0.0)) {
73 throw Slic3r::InvalidArgument(_u8L("Small Area Flow Compensation: Only the first extrusion length for small area infill compensation model can be 0"));
74 }
75 if (eLengths[i] <= eLengths[i - 1]) {
76 throw Slic3r::InvalidArgument(_u8L("Small Area Flow Compensation: Extrusion lengths for subsequent points must be increasing"));
77 }
78 }
79 }
80
81 for (size_t i = 1; i < flowComps.size(); ++i) {
82 if (flowComps[i] <= flowComps[i - 1]) {
83 throw Slic3r::InvalidArgument(_u8L("Small Area Flow Compensation: Flow compensation factors must strictly increase with extrusion length"));
84 }
85 }
86
87 if (!flowComps.empty() && !nearly_equal(flowComps.back(), 1.0)) {
88 throw Slic3r::InvalidArgument(_u8L("Small Area Flow Compensation: Final compensation factor for small area infill flow compensation model must be 1.0"));
89 }
90
91 flowModel = std::make_unique<PchipInterpolatorHelper>(eLengths, flowComps);
92
93 } catch (std::exception& e) {
94 BOOST_LOG_TRIVIAL(error) << "Error parsing small area infill compensation model: " << e.what();
95 throw;
96 }
97}
std::unique_ptr< PchipInterpolatorHelper > flowModel
Definition SmallAreaInfillFlowCompensator.hpp:28
std::vector< double > flowComps
Definition SmallAreaInfillFlowCompensator.hpp:26
std::vector< double > eLengths
Definition SmallAreaInfillFlowCompensator.hpp:25
bool nearly_equal(double a, double b)
Definition SmallAreaInfillFlowCompensator.cpp:34
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, eLengths, flowComps, flowModel, Slic3r::format(), Slic3r::GCodeConfig, and Slic3r::nearly_equal().

Here is the call graph for this function:

◆ ~SmallAreaInfillFlowCompensator()

Slic3r::SmallAreaInfillFlowCompensator::~SmallAreaInfillFlowCompensator ( )
default

Member Function Documentation

◆ flow_comp_model()

double Slic3r::SmallAreaInfillFlowCompensator::flow_comp_model ( const double line_length)
private
102{
103 if(flowModel == nullptr)
104 return 1.0;
105
106 if (line_length == 0 || line_length > max_modified_length()) {
107 return 1.0;
108 }
109
110 return flowModel->interpolate(line_length);
111}
double max_modified_length()
Definition SmallAreaInfillFlowCompensator.hpp:32

References flowModel, and max_modified_length().

Referenced by modify_flow().

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

◆ max_modified_length()

double Slic3r::SmallAreaInfillFlowCompensator::max_modified_length ( )
inlineprivate
32{ return eLengths.back(); }

References eLengths.

Referenced by flow_comp_model().

Here is the caller graph for this function:

◆ modify_flow()

double Slic3r::SmallAreaInfillFlowCompensator::modify_flow ( const double line_length,
const double dE,
const ExtrusionRole role )
114{
115 if (flowModel &&
117 return dE * flow_comp_model(line_length);
118 }
119
120 return dE;
121}
double flow_comp_model(const double line_length)
Definition SmallAreaInfillFlowCompensator.cpp:101
@ erBottomSurface
Definition ExtrusionEntity.hpp:34
@ erSolidInfill
Definition ExtrusionEntity.hpp:32
@ erTopSolidInfill
Definition ExtrusionEntity.hpp:33

References Slic3r::erBottomSurface, Slic3r::erSolidInfill, Slic3r::erTopSolidInfill, flow_comp_model(), and flowModel.

Here is the call graph for this function:

Member Data Documentation

◆ eLengths

std::vector<double> Slic3r::SmallAreaInfillFlowCompensator::eLengths
private

◆ flowComps

std::vector<double> Slic3r::SmallAreaInfillFlowCompensator::flowComps
private

◆ flowModel

std::unique_ptr<PchipInterpolatorHelper> Slic3r::SmallAreaInfillFlowCompensator::flowModel
private

The documentation for this class was generated from the following files: