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
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, ',')) {
57 flowComps.push_back(std::stod(value_str));
58 }
59 } catch (...) {
60
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) {
69 throw Slic3r::InvalidArgument(
_u8L(
"Small Area Flow Compensation: First extrusion length for small area infill compensation model must be 0"));
70 }
71 } else {
73 throw Slic3r::InvalidArgument(
_u8L(
"Small Area Flow Compensation: Only the first extrusion length for small area infill compensation model can be 0"));
74 }
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) {
83 throw Slic3r::InvalidArgument(
_u8L(
"Small Area Flow Compensation: Flow compensation factors must strictly increase with extrusion length"));
84 }
85 }
86
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
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