mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-14 11:21:18 +00:00
Share the prime-tower rule with the slicer instead of copying it
imex_wipe_tower_hull() open-coded "does this plate print a tower?" as one filament and no forcing reason. normalize_fdm_2, which is what actually clears enable_prime_tower before slicing, has a second arm the copy omitted, and reads the mixed-filament flag project-wide where the copy read the plate. Two cases went wrong in opposite directions. A ByObject plate with several objects prints no tower and the scene draws none, yet the copy validated one and could refuse the slice with "the prime tower overlaps an area reserved for IDEX/IQEX parallel printing" - with nothing on screen to move. A plate using one plain slot while some other slot in the project is a blend does print a tower, because normalize_fdm_2 keeps it for any mixed filament in the project, and the copy skipped validation entirely, so the tower could be placed in a carriage zone and sliced. prime_tower_is_printed() in libslic3r states the rule once, and both the gate and a test use it. The counts are the ones normalize_fdm_2 is handed: filament slots as authored, so a mixed slot counts once, and distinct objects rather than instances. filament_is_mixed is a project option, so it is passed in rather than read from the print preset. The test drives every combination the rule looks at and compares the verdict against normalize_fdm_2 itself, so the two cannot drift again without failing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0e44269c5e
commit
b6a2c76e5d
@@ -24,6 +24,28 @@ static const ConfigOption *option_of(const ConfigBase &config, const char *key)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool prime_tower_is_printed(const ConfigBase &config, int used_filaments, int num_objects, bool has_mixed_filament)
|
||||
{
|
||||
const auto *ept = config.option<ConfigOptionBool>("enable_prime_tower");
|
||||
if (ept == nullptr || !ept->value)
|
||||
return false;
|
||||
// normalize_fdm_2 only reconsiders the option when the plate uses a filament; below that it
|
||||
// leaves the user's choice alone, and there is no tower to reason about either way.
|
||||
if (used_filaments <= 0)
|
||||
return true;
|
||||
|
||||
const ConfigOption *timelapse = option_of(config, "timelapse_type");
|
||||
const bool smooth_timelapse = timelapse != nullptr && timelapse->getInt() == int(TimelapseType::tlSmooth);
|
||||
const auto *wrapping = config.option<ConfigOptionBool>("enable_wrapping_detection");
|
||||
const bool enable_wrapping = wrapping != nullptr && wrapping->value;
|
||||
if (smooth_timelapse || enable_wrapping)
|
||||
return true;
|
||||
|
||||
const ConfigOption *sequence = option_of(config, "print_sequence");
|
||||
const bool by_object = sequence != nullptr && sequence->getInt() == int(PrintSequence::ByObject);
|
||||
return !((used_filaments == 1 && !has_mixed_filament) || (by_object && num_objects > 1));
|
||||
}
|
||||
|
||||
WipeTowerType resolve_wipe_tower_type(const ConfigBase &config)
|
||||
{
|
||||
// printer_model is what the CLI keys its Bambu Lab detection on; the GUI's vendor flag
|
||||
|
||||
@@ -44,4 +44,17 @@ WipeTowerFootprint estimate_wipe_tower_footprint(const ConfigBase
|
||||
double layer_height,
|
||||
double max_object_height);
|
||||
|
||||
// Whether a prime tower is PRINTED for a plate. The footprint estimate above answers how big a
|
||||
// tower is and reports one for a single filament whenever the flush matrix purges, so it cannot
|
||||
// answer this; the authority is DynamicPrintConfig::normalize_fdm_2(), which clears
|
||||
// enable_prime_tower before the plate is sliced. This mirrors that rule so pre-slice consumers can
|
||||
// ask it without mutating a config, and a test pins the two together.
|
||||
//
|
||||
// used_filaments: the plate's filament SLOTS as authored - a mixed slot counts once, matching
|
||||
// Print::extruders(), which is what normalize_fdm_2 is handed.
|
||||
// num_objects: objects printed on the plate; only ByObject sequencing looks at it.
|
||||
// has_mixed_filament: filament_is_mixed is a PROJECT option, so it is passed rather than read -
|
||||
// `config` only has to carry the print preset's own keys.
|
||||
bool prime_tower_is_printed(const ConfigBase &config, int used_filaments, int num_objects, bool has_mixed_filament);
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
Reference in New Issue
Block a user