feat(orient): auto-orient the largest overhang toward the cooling fan

New printer option fan_direction (undefine/left/right/both, default
undefine) declares which side the auxiliary part-cooling airflow comes
from. When set and the printer has an auxiliary fan, auto-orient adds a
yaw rotation so the dominant overhang area faces the airflow, and newly
added primitive shapes are pre-oriented the same way (except the Cube,
whose axis-aligned bounding box the pressure-advance pattern calibration
depends on).

- FanDirection enum + fan_direction printer option (Accessory group,
  enabled only with auxiliary_fan)
- orient engine: weighted overhang areas per candidate, yaw-direction
  search, vertical rotation applied on top of the primary orientation;
  the cooling weights are taken from the candidate actually chosen,
  including the flat-bottom tie-break
- orient_for_cooling() for primitive placement
- set fan_direction=left on H2C/H2D/H2D Pro/X1/X1E/P1S 0.4 profiles
  (X1C/H2S/P2S/X2D/Qidi X-Max 4 already carried the key, which now
  takes effect)

With fan_direction unset or no auxiliary fan the vertical rotation stays
identity and auto-orient results are unchanged; slicing and g-code are
never affected.
This commit is contained in:
SoftFever
2026-07-10 16:21:48 +08:00
parent 93a81179a1
commit b12aad6a8c
15 changed files with 283 additions and 19 deletions

View File

@@ -512,6 +512,14 @@ static t_config_enum_values s_keys_map_NozzleType {
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(NozzleType)
static t_config_enum_values s_keys_map_FanDirection {
{ "undefine", int(FanDirection::fdUndefine) },
{ "left", int(FanDirection::fdLeft) },
{ "right", int(FanDirection::fdRight) },
{ "both", int(FanDirection::fdBoth) }
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(FanDirection)
static t_config_enum_values s_keys_map_PrinterStructure {
{"undefine", int(PrinterStructure::psUndefine)},
{"corexy", int(PrinterStructure::psCoreXY)},
@@ -3997,6 +4005,21 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("fan_direction", coEnum);
def->label = L("Fan direction");
def->tooltip = L("Cooling fan direction of the printer");
def->enum_keys_map = &ConfigOptionEnum<FanDirection>::get_enum_values();
def->enum_values.push_back("undefine");
def->enum_values.push_back("left");
def->enum_values.push_back("right");
def->enum_values.push_back("both");
def->enum_labels.push_back(L("Undefined"));
def->enum_labels.push_back(L("Left"));
def->enum_labels.push_back(L("Right"));
def->enum_labels.push_back(L("Both"));
def->mode = comDevelop;
def->set_default_value(new ConfigOptionEnum<FanDirection>(fdUndefine));
def = this->add("fan_speedup_time", coFloat);
// Label is set in Tab.cpp in the Line object.
//def->label = L("Fan speed-up time");