mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
FIX: filament group crash in cli mode
1.Always do filament group to get correct filament map jira:NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Ie4e61c310f6c0cfeacb2a49c4f065f9674b6a35f (cherry picked from commit 242554557b1ecd72355841826af707580fc583b6)
This commit is contained in:
@@ -1102,57 +1102,37 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first
|
||||
std::vector<std::set<int>>geometric_unprintables = get_geometrical_unprintables(m_print->get_unprintable_filament_ids(), print_config);
|
||||
std::vector<std::set<int>>physical_unprintables = get_physical_unprintables(used_filaments, print_config);
|
||||
|
||||
if (nozzle_nums > 1) {
|
||||
filament_maps = m_print->get_filament_maps();
|
||||
map_mode = m_print->get_filament_map_mode();
|
||||
// only check and map in sequence mode, in by object mode, we check the map in print.cpp
|
||||
if (print_config->print_sequence != PrintSequence::ByObject || m_print->objects().size() == 1) {
|
||||
if (map_mode == FilamentMapMode::fmmAuto) {
|
||||
const PrintConfig* print_config = m_print_config_ptr;
|
||||
if (!print_config && m_print_object_ptr) {
|
||||
print_config = &(m_print_object_ptr->print()->config());
|
||||
}
|
||||
|
||||
filament_maps = ToolOrdering::get_recommended_filament_maps(layer_filaments, print_config, m_print, physical_unprintables, geometric_unprintables);
|
||||
|
||||
if (filament_maps.empty())
|
||||
return;
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) { return value + 1; });
|
||||
m_print->update_filament_maps_to_config(filament_maps);
|
||||
filament_maps = m_print->get_filament_maps();
|
||||
map_mode = m_print->get_filament_map_mode();
|
||||
// only check and map in sequence mode, in by object mode, we check the map in print.cpp
|
||||
if (print_config->print_sequence != PrintSequence::ByObject || m_print->objects().size() == 1) {
|
||||
if (map_mode == FilamentMapMode::fmmAuto) {
|
||||
const PrintConfig* print_config = m_print_config_ptr;
|
||||
if (!print_config && m_print_object_ptr) {
|
||||
print_config = &(m_print_object_ptr->print()->config());
|
||||
}
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) { return value - 1; });
|
||||
|
||||
if (!check_tpu_group(used_filaments, filament_maps, print_config)) {
|
||||
if (map_mode == FilamentMapMode::fmmManual) {
|
||||
throw Slic3r::RuntimeError(std::string("Manual grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
else {
|
||||
throw Slic3r::RuntimeError(std::string("Auto grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// we just need to change the map to 0 based
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) {return value - 1; });
|
||||
}
|
||||
}
|
||||
else if (nozzle_nums == 1) {
|
||||
filament_maps = m_print->get_filament_maps();
|
||||
filament_maps.resize(number_of_extruders, 1);
|
||||
bool invalid = std::any_of(filament_maps.begin(), filament_maps.end(), [](int value) { return value != 1; });
|
||||
if (invalid) {
|
||||
assert(false);
|
||||
std::stringstream sstream;
|
||||
for (size_t i = 0; i < filament_maps.size(); ++i) {
|
||||
if (i != 0)
|
||||
sstream << " ";
|
||||
sstream << filament_maps[i];
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(error) << "The filament_map of single printer is invalid. filament_map = " << sstream.str();
|
||||
std::fill(filament_maps.begin(), filament_maps.end(), 1);
|
||||
filament_maps = ToolOrdering::get_recommended_filament_maps(layer_filaments, print_config, m_print, physical_unprintables, geometric_unprintables);
|
||||
|
||||
if (filament_maps.empty())
|
||||
return;
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) { return value + 1; });
|
||||
m_print->update_filament_maps_to_config(filament_maps);
|
||||
}
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) { return value - 1; });
|
||||
|
||||
if (!check_tpu_group(used_filaments, filament_maps, print_config)) {
|
||||
if (map_mode == FilamentMapMode::fmmManual) {
|
||||
throw Slic3r::RuntimeError(std::string("Manual grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
else {
|
||||
throw Slic3r::RuntimeError(std::string("Auto grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// we just need to change the map to 0 based
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) {return value - 1; });
|
||||
}
|
||||
|
||||
std::vector<std::vector<unsigned int>>filament_sequences;
|
||||
@@ -1173,7 +1153,7 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first
|
||||
first_layer_filaments = m_layer_tools[0].extruders;
|
||||
|
||||
// other_layers_seq: the layer_idx and extruder_idx are base on 1
|
||||
auto get_custom_seq = [&other_layers_seqs,&reorder_first_layer,&first_layer_filaments](int layer_idx, std::vector<int>& out_seq) -> bool {
|
||||
auto get_custom_seq = [&other_layers_seqs, &reorder_first_layer, &first_layer_filaments](int layer_idx, std::vector<int>& out_seq) -> bool {
|
||||
if (!reorder_first_layer && layer_idx == 0) {
|
||||
out_seq.resize(first_layer_filaments.size());
|
||||
std::transform(first_layer_filaments.begin(), first_layer_filaments.end(), out_seq.begin(), [](auto item) {return item + 1; });
|
||||
|
||||
@@ -2115,36 +2115,34 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
if (this->config().print_sequence == PrintSequence::ByObject) {
|
||||
// Order object instances for sequential print.
|
||||
print_object_instances_ordering = sort_object_instances_by_model_order(*this);
|
||||
if (m_config.nozzle_diameter.size() > 1) {
|
||||
std::vector<std::vector<unsigned int>> all_filaments;
|
||||
for (print_object_instance_sequential_active = print_object_instances_ordering.begin(); print_object_instance_sequential_active != print_object_instances_ordering.end(); ++print_object_instance_sequential_active) {
|
||||
tool_ordering = ToolOrdering(*(*print_object_instance_sequential_active)->print_object, initial_extruder_id);
|
||||
for (const auto& layer_tool : tool_ordering.layer_tools()) {
|
||||
all_filaments.emplace_back(layer_tool.extruders);
|
||||
}
|
||||
std::vector<std::vector<unsigned int>> all_filaments;
|
||||
for (print_object_instance_sequential_active = print_object_instances_ordering.begin(); print_object_instance_sequential_active != print_object_instances_ordering.end(); ++print_object_instance_sequential_active) {
|
||||
tool_ordering = ToolOrdering(*(*print_object_instance_sequential_active)->print_object, initial_extruder_id);
|
||||
for (const auto& layer_tool : tool_ordering.layer_tools()) {
|
||||
all_filaments.emplace_back(layer_tool.extruders);
|
||||
}
|
||||
}
|
||||
|
||||
auto used_filaments = collect_sorted_used_filaments(all_filaments);
|
||||
auto physical_unprintables = ToolOrdering::get_physical_unprintables(used_filaments, &m_config);
|
||||
auto geometric_unprintables = ToolOrdering::get_geometrical_unprintables(get_unprintable_filament_ids(), &m_config);
|
||||
auto used_filaments = collect_sorted_used_filaments(all_filaments);
|
||||
auto physical_unprintables = ToolOrdering::get_physical_unprintables(used_filaments, &m_config);
|
||||
auto geometric_unprintables = ToolOrdering::get_geometrical_unprintables(get_unprintable_filament_ids(), &m_config);
|
||||
|
||||
std::vector<int>filament_maps = this->get_filament_maps();
|
||||
auto map_mode = get_filament_map_mode();
|
||||
// get recommended filament map
|
||||
if (map_mode == FilamentMapMode::fmmAuto) {
|
||||
filament_maps = ToolOrdering::get_recommended_filament_maps(all_filaments, &config(), this, physical_unprintables, geometric_unprintables);
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) { return value + 1; });
|
||||
update_filament_maps_to_config(filament_maps);
|
||||
std::vector<int>filament_maps = this->get_filament_maps();
|
||||
auto map_mode = get_filament_map_mode();
|
||||
// get recommended filament map
|
||||
if (map_mode == FilamentMapMode::fmmAuto) {
|
||||
filament_maps = ToolOrdering::get_recommended_filament_maps(all_filaments, &config(), this, physical_unprintables, geometric_unprintables);
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) { return value + 1; });
|
||||
update_filament_maps_to_config(filament_maps);
|
||||
}
|
||||
// check map valid both in auto and mannual mode
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) {return value - 1; });
|
||||
if (!ToolOrdering::check_tpu_group(used_filaments, filament_maps, &m_config)) {
|
||||
if (map_mode == FilamentMapMode::fmmManual) {
|
||||
throw Slic3r::RuntimeError(std::string("Manual grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
// check map valid both in auto and mannual mode
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) {return value - 1; });
|
||||
if (!ToolOrdering::check_tpu_group(used_filaments, filament_maps, &m_config)) {
|
||||
if (map_mode == FilamentMapMode::fmmManual) {
|
||||
throw Slic3r::RuntimeError(std::string("Manual grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
else {
|
||||
throw Slic3r::RuntimeError(std::string("Auto grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
else {
|
||||
throw Slic3r::RuntimeError(std::string("Auto grouping error: TPU can only be placed in a nozzle alone."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user