Add "Enforcers only" option into support combo box

And also make it work
This commit is contained in:
tamasmeszaros 2022-12-12 16:23:33 +01:00
parent 3a7af1c1de
commit 7b207aaf5c
8 changed files with 49 additions and 20 deletions

View File

@ -502,6 +502,7 @@ static std::vector<std::string> s_Preset_sla_print_options {
"support_max_bridges_on_pillar",
"support_pillar_connection_mode",
"support_buildplate_only",
"support_enforcers_only",
"support_pillar_widening_factor",
"support_base_diameter",
"support_base_height",

View File

@ -3661,6 +3661,13 @@ void PrintConfigDef::init_sla_params()
def->mode = comSimple;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("support_enforcers_only", coBool);
def->label = L("Support only in enforced regions");
def->category = L("Supports");
def->tooltip = L("Only create support if it lies in a support enforcer.");
def->mode = comSimple;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("support_pillar_widening_factor", coFloat);
def->label = L("Pillar widening factor");
def->category = L("Supports");

View File

@ -858,6 +858,9 @@ PRINT_CONFIG_CLASS_DEFINE(
// Generate only ground facing supports
((ConfigOptionBool, support_buildplate_only))
// Generate only ground facing supports
((ConfigOptionBool, support_enforcers_only))
// TODO: unimplemented at the moment. This coefficient will have an impact
// when bridges and pillars are merged. The resulting pillar should be a bit
// thicker than the ones merging into it. How much thicker? I don't know

View File

@ -35,7 +35,7 @@ bool is_zero_elevation(const SLAPrintObjectConfig &c)
sla::SupportTreeConfig make_support_cfg(const SLAPrintObjectConfig& c)
{
sla::SupportTreeConfig scfg;
scfg.enabled = c.supports_enable.getBool();
scfg.tree_type = c.support_tree_type.value;
scfg.head_front_radius_mm = 0.5*c.support_head_front_diameter.getFloat();
@ -58,7 +58,7 @@ sla::SupportTreeConfig make_support_cfg(const SLAPrintObjectConfig& c)
scfg.pillar_base_safety_distance_mm =
c.support_base_safety_distance.getFloat() < EPSILON ?
scfg.safety_distance_mm : c.support_base_safety_distance.getFloat();
scfg.max_bridges_on_pillar = unsigned(c.support_max_bridges_on_pillar.getInt());
return scfg;
@ -827,6 +827,7 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vector<t_conf
steps.emplace_back(slaposObjectSlice);
} else if (
opt_key == "support_points_density_relative"
|| opt_key == "support_enforcers_only"
|| opt_key == "support_points_minimal_distance") {
steps.emplace_back(slaposSupportPoints);
} else if (

View File

@ -404,11 +404,16 @@ void SLAPrint::Steps::slice_model(SLAPrintObject &po)
// report_status(-2, "", SlicingStatus::RELOAD_SLA_PREVIEW);
}
static void filter_support_points_by_modifiers(
sla::SupportPoints &pts,
const std::vector<ExPolygons> &blockers,
const std::vector<ExPolygons> &enforcers,
const std::vector<float> &slice_grid)
struct SuppPtMask {
const std::vector<ExPolygons> &blockers;
const std::vector<ExPolygons> &enforcers;
bool enforcers_only = false;
};
static void filter_support_points_by_modifiers(sla::SupportPoints &pts,
const SuppPtMask &mask,
const std::vector<float> &slice_grid)
{
assert((blockers.empty() || blockers.size() == slice_grid.size()) &&
(enforcers.empty() || enforcers.size() == slice_grid.size()));
@ -423,24 +428,30 @@ static void filter_support_points_by_modifiers(
if (it != slice_grid.end()) {
size_t idx = std::distance(slice_grid.begin(), it);
bool is_enforced = false;
if (idx < enforcers.size()) {
if (idx < mask.enforcers.size()) {
for (size_t enf_idx = 0;
!is_enforced && enf_idx < enforcers[idx].size();
!is_enforced && enf_idx < mask.enforcers[idx].size();
++enf_idx)
{
if (enforcers[idx][enf_idx].contains(sp2d))
if (mask.enforcers[idx][enf_idx].contains(sp2d))
is_enforced = true;
}
}
bool is_blocked = false;
if (!is_enforced && idx < blockers.size()) {
for (size_t blk_idx = 0;
!is_blocked && blk_idx < blockers[idx].size();
++blk_idx)
{
if (blockers[idx][blk_idx].contains(sp2d))
is_blocked = true;
if (!is_enforced) {
if (!mask.enforcers_only) {
if (idx < mask.blockers.size()) {
for (size_t blk_idx = 0;
!is_blocked && blk_idx < mask.blockers[idx].size();
++blk_idx)
{
if (mask.blockers[idx][blk_idx].contains(sp2d))
is_blocked = true;
}
}
} else {
is_blocked = true;
}
}
@ -527,7 +538,8 @@ void SLAPrint::Steps::support_points(SLAPrintObject &po)
return vol->is_support_enforcer();
});
filter_support_points_by_modifiers(points, blockers, enforcers, po.m_model_height_levels);
SuppPtMask mask{blockers, enforcers, po.config().support_enforcers_only.getBool()};
filter_support_points_by_modifiers(points, mask, po.m_model_height_levels);
po.m_supportdata->input.pts = points;

View File

@ -374,6 +374,7 @@ void ConfigManipulation::toggle_print_sla_options(DynamicPrintConfig* config)
toggle_field("support_pillar_connection_mode", supports_en && is_default_tree);
toggle_field("support_tree_type", supports_en);
toggle_field("support_buildplate_only", supports_en);
toggle_field("support_enforcers_only", supports_en);
toggle_field("support_base_diameter", supports_en);
toggle_field("support_base_height", supports_en);
toggle_field("support_base_safety_distance", supports_en);

View File

@ -545,10 +545,15 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
const bool supports_enable = selection == _("None") ? false : true;
new_conf.set_key_value("supports_enable", new ConfigOptionBool(supports_enable));
new_conf.set_key_value("support_enforcers_only", new ConfigOptionBool(false));
if (selection == _("Everywhere"))
new_conf.set_key_value("support_buildplate_only", new ConfigOptionBool(false));
else if (selection == _("Support on build plate only"))
new_conf.set_key_value("support_buildplate_only", new ConfigOptionBool(true));
else if (selection == _("For support enforcers only")) {
new_conf.set_key_value("support_enforcers_only", new ConfigOptionBool(true));
}
}
tab->load_config(new_conf);
@ -559,8 +564,6 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
ConfigOptionDef support_def_sla = support_def;
support_def_sla.set_default_value(new ConfigOptionStrings{ "None" });
assert(support_def_sla.enum_labels[2] == L("For support enforcers only"));
support_def_sla.enum_labels.erase(support_def_sla.enum_labels.begin() + 2);
option = Option(support_def_sla, "support");
option.opt.full_width = true;
line.append_option(option);

View File

@ -4777,6 +4777,7 @@ void TabSLAPrint::build()
optgroup->append_single_option_line("support_pillar_connection_mode");
optgroup->append_single_option_line("support_buildplate_only");
optgroup->append_single_option_line("support_enforcers_only");
optgroup->append_single_option_line("support_pillar_widening_factor");
optgroup->append_single_option_line("support_base_diameter");
optgroup->append_single_option_line("support_base_height");