diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 75dedc732..56236f87c 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -36,6 +36,20 @@ static std::setget_filament_by_type(const std::vector& used_f return target_filaments; } + +/** + * @brief Determines the unprintable filaments for each extruder based on its physical attributes + * + * Currently, the criteria for determining unprintable filament include the following: + * 1. TPU filaments can only be placed in the master extruder and must be grouped alone. + * 2. We only support at most 1 tpu filament. + * 3. An extruder can only accommodate filament with a hardness requirement lower than that of its nozzle. + * If extruder num is 1, just return an empty vector. + * + * @param used_filaments Totally used filaments when slicing + * @param config Config that stores releted params + * @return A vector of sets representing unprintable filaments for each extruder + */ std::vector> ToolOrdering::get_physical_unprintables(const std::vector& used_filaments, const PrintConfig* config) { // master saved in config is 1 based,so we should transfer to 0 based here @@ -45,8 +59,12 @@ std::vector> ToolOrdering::get_physical_unprintables(const std::ve throw Slic3r::RuntimeError(std::string("Only supports up to one TPU filament.")); } + int extruder_num = config->nozzle_diameter.size(); // consider tpu, only place tpu in extruder with ams - std::vector>physical_unprintables(config->nozzle_diameter.size()); + std::vector>physical_unprintables(extruder_num); + if (extruder_num < 2) + return physical_unprintables; + int extruder_without_tpu = 1 - master_extruder_id; for (auto& f : tpu_filaments) physical_unprintables[extruder_without_tpu].insert(f); @@ -66,11 +84,25 @@ std::vector> ToolOrdering::get_physical_unprintables(const std::ve return physical_unprintables; } +/** + * @brief Determines the unprintable filaments for each extruder based on its printable area. + * + * The returned array will always have the same size as the number of extruders. + * If extruder num is 1, just return an empty vector. + * If an extruder has no unprintable filaments, an empty set will also be returned + * + * @param unprintable_arrs An array of unprintable filaments for each extruder + * @param config Containing extruder nums or any other info requested + * @return A vector of sets representing unprintable filaments for each extruder + */ std::vector> ToolOrdering::get_geometrical_unprintables(const std::vector>& unprintable_arrs, const PrintConfig* config) { auto arrs_idx_switched = unprintable_arrs; int extruder_nums = config->nozzle_diameter.size(); std::vector> unprintables(extruder_nums); + if(extruder_nums < 2) + return unprintables; + for (auto& arr : arrs_idx_switched) for (auto& item : arr) item -= 1;