From e2f96590cf59e48fcc79a44912d9b4c91d587e0b Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Mon, 27 Mar 2023 16:05:31 +0800 Subject: [PATCH] ENH: CLI: add normative_check logic Change-Id: I7a02fefb2a161b27a35ad73102d8c57dbffa7c6b (cherry picked from commit 3de468b341e95336611ff527453160131ec04b65) --- src/BambuStudio.cpp | 18 ++++++++++++++++-- src/libslic3r/PrintConfig.cpp | 7 +++++++ src/libslic3r/Utils.hpp | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index 8be5a4eaa..5d71e39af 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -490,7 +490,7 @@ int CLI::run(int argc, char **argv) PlateDataPtrs plate_data_src; int arrange_option; int plate_to_slice = 0, filament_count = 0; - bool first_file = true, is_bbl_3mf = false, need_arrange = true, has_thumbnails = false, up_config_to_date = false; + bool first_file = true, is_bbl_3mf = false, need_arrange = true, has_thumbnails = false, up_config_to_date = false, normative_check = true; Semver file_version; std::map orients_requirement; std::vector project_presets; @@ -504,6 +504,9 @@ int CLI::run(int argc, char **argv) ConfigOptionInt* slice_option = m_config.option("slice"); if (slice_option) plate_to_slice = slice_option->value; + ConfigOptionBool* normative_check_option = m_config.option("normative_check"); + if (normative_check_option) + normative_check = normative_check_option->value; ConfigOptionBool* uptodate_option = m_config.option("uptodate"); if (uptodate_option) up_config_to_date = uptodate_option->value; @@ -513,7 +516,7 @@ int CLI::run(int argc, char **argv) BOOST_LOG_TRIVIAL(info) << "found a gcode file:" << file << ", will start as gcode viewer\n"; break; }*/ - BOOST_LOG_TRIVIAL(info) << "plate_to_slice="<< plate_to_slice << std::endl; + BOOST_LOG_TRIVIAL(info) << boost::format("plate_to_slice=%1%, normative_check=%2%")%plate_to_slice %normative_check; //if (!start_as_gcodeviewer) { for (const std::string& file : m_input_files) { if (!boost::filesystem::exists(file)) { @@ -563,6 +566,17 @@ int CLI::run(int argc, char **argv) BOOST_LOG_TRIVIAL(info) << boost::format("old 3mf version %1%, need to translate")%file_version.to_string(); } + if (normative_check) { + ConfigOptionStrings* postprocess_scripts = config.option("post_process"); + if (postprocess_scripts) { + std::vector postprocess_values = postprocess_scripts->values; + if (postprocess_values.size() > 0) { + BOOST_LOG_TRIVIAL(error) << boost::format("normative_check: postprocess not supported, array size %1%")%postprocess_values.size(); + flush_and_exit(CLI_POSTPROCESS_NOT_SUPPORTED); + } + } + } + /*for (ModelObject *model_object : model.objects) for (ModelInstance *model_instance : model_object->instances) { diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index c69ddad90..4e91ec4e3 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4638,6 +4638,13 @@ CLIActionsConfigDef::CLIActionsConfigDef() def->cli_params = "option"; def->set_default_value(new ConfigOptionBool(false)); + def = this->add("normative_check", coBool); + def->label = L("Normative check"); + def->tooltip = L("Check the normative items."); + def->cli = "normative_check"; + def->cli_params = "option"; + def->set_default_value(new ConfigOptionBool(true)); + /*def = this->add("help_fff", coBool); def->label = L("Help (FFF options)"); def->tooltip = L("Show the full list of print/G-code configuration options."); diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index b04628e65..98b8e33fc 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -35,6 +35,7 @@ #define CLI_3MF_NEW_MACHINE_NOT_SUPPORTED -16 #define CLI_PROCESS_NOT_COMPATIBLE -17 #define CLI_INVALID_VALUES_IN_3MF -18 +#define CLI_POSTPROCESS_NOT_SUPPORTED -19 #define CLI_NO_SUITABLE_OBJECTS -50