[Feature] Add a new feature that allow user to insert extra solid infills (#10611)

* refactor Infill rotation template

* clean up comments

* set default solid_infill_rotate_template to empty

* Fix an issue that infill_direction solid_infill_direction not working as expected

* Add Extra Solid Infill Feature
Introduced a new feature to insert extra solid infills at specific layers for enhanced strength in 3D prints.

* fix doc error

* fix image name

* support "#K" for Explicit Layer List

* update wiki
This commit is contained in:
SoftFever
2025-09-03 22:16:31 +08:00
committed by GitHub
parent 266bfeb9e2
commit 31869bfbd1
11 changed files with 175 additions and 18 deletions

View File

@@ -451,13 +451,27 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
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);
}
break;
} else if (m_opt.opt_key == "extra_solid_infills") {
string ustr(str.utf8_string());
// New rule: accept either interval form (N or N#K) or explicit list (e.g. 1,7,9), with optional quotes.
const std::regex rx_interval(u8R"(^\s*['"]?\s*\d+\s*(?:#\s*\d*)?\s*['"]?\s*$)");
// List entries may be plain numbers or number with optional #K count, e.g., 5, 9#2, 18
const std::regex rx_list(u8R"(^\s*['"]?\s*\d+(?:\s*#\s*\d*)?(?:\s*,\s*\d+(?:\s*#\s*\d*)?)*\s*['"]?\s*$)");
bool is_valid = ustr.empty() || std::regex_match(ustr, rx_interval) || std::regex_match(ustr, rx_list);
if (!is_valid) {
show_error(m_parent, format_wxstr(_L("Invalid pattern. Use N, N#K, or a comma-separated list with optional #K per entry. Examples: 5, 5#2, 1,7,9, 5,9#2,18.")));
wxString old_value(boost::any_cast<std::string>(m_value));
this->set_value(old_value, true); // Revert to previous value
}
// Valid string or empty, so update m_value with the new string from the control.
m_value = into_u8(str);
break;
}
m_value = into_u8(str);