From 98f3aaa4bf4728647b49d66853ee71561f03589c Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Fri, 14 Apr 2023 15:21:11 +0800 Subject: [PATCH] ENH: CLI: add the gcode path check logic for cli Change-Id: I424a93d9ca945598da861a1905da07ae14663157 --- src/BambuStudio.cpp | 5 +++++ src/libslic3r/Print.cpp | 1 + src/libslic3r/Print.hpp | 9 +++++++++ src/libslic3r/Utils.hpp | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index a56d650aa..a5c10d514 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -2065,6 +2065,11 @@ int CLI::run(int argc, char **argv) print->process(); } if (printer_technology == ptFFF) { + std::string conflict_result = dynamic_cast(print)->get_conflict_string(); + if (!conflict_result.empty()) { + BOOST_LOG_TRIVIAL(error) << "plate "<< index+1<< ": found slicing result conflict!"<< std::endl; + flush_and_exit(CLI_GCODE_PATH_CONFLICTS); + } // The outfile is processed by a PlaceholderParser. //outfile = part_plate->get_tmp_gcode_path(); if (outfile_dir.empty()) { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index dc1f4d4fe..c06588977 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1691,6 +1691,7 @@ void Print::process(bool use_cache) if (conflictRes.has_value()) { m_conflict_result.set(conflictRes.value().first, conflictRes.value().second); + BOOST_LOG_TRIVIAL(error) << boost::format("gcode path conflicts found between %1% and %2%")%conflictRes.value().first %conflictRes.value().second; } else { m_conflict_result.reset(); } diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 0e5e9c368..ae19bce85 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -772,6 +772,15 @@ public: bool is_support_used() const {return m_support_used;} bool is_BBL_Printer() const { return m_isBBLPrinter;} void set_BBL_Printer(const bool isBBL) { m_isBBLPrinter = isBBL;} + std::string get_conflict_string() const + { + std::string result; + if (m_conflict_result.conflicted) { + result = "Found gcode path conflicts between object " + m_conflict_result.obj1 + " and " + m_conflict_result.obj2; + } + + return result; + } //BBS static StringObjectException sequential_print_clearance_valid(const Print &print, Polygons *polygons = nullptr, std::vector>* height_polygons = nullptr); diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 98b8e33fc..120db2ff9 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -50,7 +50,8 @@ #define CLI_TRIANGLE_COUNT_EXCEEDS_LIMIT -59 #define CLI_NO_SUITABLE_OBJECTS_AFTER_SKIP -60 -#define CLI_SLICING_ERROR -100 +#define CLI_SLICING_ERROR -100 +#define CLI_GCODE_PATH_CONFLICTS -101 namespace boost { namespace filesystem { class directory_entry; }}