Add template metalanguage support for infill rotation template (#9996)

* Add some new non-overlapping functions for rotation surfaces/infills

I can't post the entire package of changes yet, but this is just the beginning. These features do not affect the latest changes to the pattern rotation system. They are merely adding new functionality.

* Added relative rotation of the infill according to the template.

* Update PrintConfig.cpp

* Update PrintConfig.cpp

* Update PrintConfig.cpp

* Add height limitation

* Both sparse and solid. +one-time instructions

* implementation v3

need for clean code in future

* + Multiply Instructions

* Add solid layers into sparse infill

* Update Layer.hpp

* Update PrintObject.cpp

* Update Tab.cpp

* Remove some bugs and increase quality

* rename apply_model_direction to align_infill_direction_to_model

* Change the data type of top_surface_direction and bottom_surface_direction to float so that they are consistent with other infill direction parameters.

* remove top_surface_direction and bottom surface_direction options

* clean code

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
π²
2025-07-25 15:29:08 +03:00
committed by GitHub
parent 3d16c7f4c8
commit 1ef427f661
9 changed files with 230 additions and 14 deletions

View File

@@ -431,10 +431,34 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
set_value(str, true);
}
} else if (m_opt.opt_key == "sparse_infill_rotate_template" || m_opt.opt_key == "solid_infill_rotate_template") {
if (!ConfigOptionFloats::validate_string(str.utf8_string())) {
show_error(m_parent, format_wxstr(_L("This parameter expects a comma-delimited list of numbers. E.g, \"0,90\".")));
wxString old_value(boost::any_cast<std::string>(m_value));
this->set_value(old_value, true); // Revert to previous value
string ustr(str.utf8_string());
if (!ConfigOptionFloats::validate_string(ustr)) {
string v;
std::smatch match;
string ps = (m_opt.opt_key == "sparse_infill_rotate_template") ?
u8"[SODMR]?[BT][!]?|[SODMR]?[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[SODMR]?[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[BT]?[!*]?" :
u8"[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[!*]?";
//if (m_opt.opt_key == "sparse_infill_rotate_template") {
//string ps = u8"[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[SODMR]?[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[";
//if (m_opt.opt_key == "sparse_infill_rotate_template") {
// ps = u8"[BT][!]?|" + ps ;
//}
//ps += u8"BT]?[!*]?";
while (std::regex_search(ustr, match, std::regex(ps))) {
for (auto x : match) v += x.str() + ", ";
ustr = match.suffix().str();
}
v = v.substr(0, v.length() - 2);
try {
this->set_value(from_u8(v), true);
m_value = into_u8(v);
} catch (...) {
show_error(m_parent, format_wxstr(_L("This parameter expects a valid template.")));
wxString old_value(boost::any_cast<std::string>(m_value));
this->set_value(old_value, true); // Revert to previous value
throw;
}
} else {
// Valid string, so update m_value with the new string from the control.
m_value = into_u8(str);