mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-17 11:47:54 -06:00
ENH: add the time limit and triangle limit for cli slicing
Change-Id: I80d6e58dca6648427dbe4cfbc01eabdedfa79f52
This commit is contained in:
parent
6fab32c98b
commit
662453f419
3 changed files with 52 additions and 1 deletions
|
@ -60,6 +60,7 @@ using namespace nlohmann;
|
||||||
#include "libslic3r/Format/OBJ.hpp"
|
#include "libslic3r/Format/OBJ.hpp"
|
||||||
#include "libslic3r/Format/SL1.hpp"
|
#include "libslic3r/Format/SL1.hpp"
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
|
#include "libslic3r/Time.hpp"
|
||||||
#include "libslic3r/Thread.hpp"
|
#include "libslic3r/Thread.hpp"
|
||||||
#include "libslic3r/BlacklistedLibraryCheck.hpp"
|
#include "libslic3r/BlacklistedLibraryCheck.hpp"
|
||||||
|
|
||||||
|
@ -1735,6 +1736,7 @@ int CLI::run(int argc, char **argv)
|
||||||
std::string export_3mf_file, load_slice_data_dir, export_slice_data_dir;
|
std::string export_3mf_file, load_slice_data_dir, export_slice_data_dir;
|
||||||
std::string outfile_dir = m_config.opt_string("outputdir");
|
std::string outfile_dir = m_config.opt_string("outputdir");
|
||||||
std::vector<ThumbnailData*> calibration_thumbnails;
|
std::vector<ThumbnailData*> calibration_thumbnails;
|
||||||
|
int max_slicing_time_per_plate = 0, max_triangle_count_per_plate = 0;
|
||||||
for (auto const &opt_key : m_actions) {
|
for (auto const &opt_key : m_actions) {
|
||||||
if (opt_key == "help") {
|
if (opt_key == "help") {
|
||||||
this->print_help();
|
this->print_help();
|
||||||
|
@ -1767,6 +1769,10 @@ int CLI::run(int argc, char **argv)
|
||||||
}
|
}
|
||||||
} else if (opt_key == "uptodate") {
|
} else if (opt_key == "uptodate") {
|
||||||
//already processed before
|
//already processed before
|
||||||
|
} else if (opt_key == "mtcpp") {
|
||||||
|
max_triangle_count_per_plate = m_config.option<ConfigOptionInt>("mtcpp")->value;
|
||||||
|
} else if (opt_key == "mstpp") {
|
||||||
|
max_slicing_time_per_plate = m_config.option<ConfigOptionInt>("mstpp")->value;
|
||||||
} else if (opt_key == "export_stl") {
|
} else if (opt_key == "export_stl") {
|
||||||
for (auto &model : m_models)
|
for (auto &model : m_models)
|
||||||
model.add_default_instances();
|
model.add_default_instances();
|
||||||
|
@ -1836,6 +1842,8 @@ int CLI::run(int argc, char **argv)
|
||||||
BOOST_LOG_TRIVIAL(info) << "Skip plate " << index+1 << std::endl;
|
BOOST_LOG_TRIVIAL(info) << "Skip plate " << index+1 << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
long long start_time = 0, end_time = 0;
|
||||||
|
start_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||||
//get the current partplate
|
//get the current partplate
|
||||||
Slic3r::GUI::PartPlate* part_plate = partplate_list.get_plate(index);
|
Slic3r::GUI::PartPlate* part_plate = partplate_list.get_plate(index);
|
||||||
part_plate->get_print(&print, &gcode_result, &print_index);
|
part_plate->get_print(&print, &gcode_result, &print_index);
|
||||||
|
@ -1866,13 +1874,32 @@ int CLI::run(int argc, char **argv)
|
||||||
flush_and_exit(CLI_NO_SUITABLE_OBJECTS);
|
flush_and_exit(CLI_NO_SUITABLE_OBJECTS);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
long long triangle_count = 0;
|
||||||
for (ModelObject* model_object : model.objects)
|
for (ModelObject* model_object : model.objects)
|
||||||
for (ModelInstance *i : model_object->instances)
|
for (ModelInstance *i : model_object->instances)
|
||||||
|
{
|
||||||
if (i->print_volume_state == ModelInstancePVS_Partly_Outside)
|
if (i->print_volume_state == ModelInstancePVS_Partly_Outside)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(error) << "plate "<< index+1<< ": Found Object " << model_object->name <<" partly inside, can not be sliced." << std::endl;
|
BOOST_LOG_TRIVIAL(error) << "plate "<< index+1<< ": Found Object " << model_object->name <<" partly inside, can not be sliced." << std::endl;
|
||||||
flush_and_exit(CLI_OBJECTS_PARTLY_INSIDE);
|
flush_and_exit(CLI_OBJECTS_PARTLY_INSIDE);
|
||||||
}
|
}
|
||||||
|
else if ((max_triangle_count_per_plate != 0) && (i->print_volume_state == ModelInstancePVS_Inside))
|
||||||
|
{
|
||||||
|
for (const ModelVolume* vol : model_object->volumes)
|
||||||
|
{
|
||||||
|
if (vol->is_model_part()) {
|
||||||
|
size_t volume_triangle_count = vol->mesh().facets_count();
|
||||||
|
triangle_count += volume_triangle_count;
|
||||||
|
BOOST_LOG_TRIVIAL(info) << boost::format("volume triangle count %1%, total %2%")%volume_triangle_count %triangle_count;
|
||||||
|
if (triangle_count > max_triangle_count_per_plate)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "plate "<< index+1<< ": triangle count " << triangle_count <<" exceeds the limit:" << max_triangle_count_per_plate;
|
||||||
|
flush_and_exit(CLI_TRIANGLE_COUNT_EXCEEDS_LIMIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// BBS: TODO
|
// BBS: TODO
|
||||||
//BOOST_LOG_TRIVIAL(info) << boost::format("print_volume {%1%,%2%,%3%}->{%4%, %5%, %6%}, has %7% printables") % print_volume.min(0) % print_volume.min(1)
|
//BOOST_LOG_TRIVIAL(info) << boost::format("print_volume {%1%,%2%,%3%}->{%4%, %5%, %6%}, has %7% printables") % print_volume.min(0) % print_volume.min(1)
|
||||||
|
@ -2000,6 +2027,15 @@ int CLI::run(int argc, char **argv)
|
||||||
fs::remove_all(plate_dir);
|
fs::remove_all(plate_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (max_slicing_time_per_plate != 0) {
|
||||||
|
end_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||||
|
long long time_cost = end_time - start_time;
|
||||||
|
if (time_cost > max_slicing_time_per_plate) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << boost::format("plate %1%'s slice time %2% exceeds the limit %3%, return error.")
|
||||||
|
%(index+1) %time_cost %max_slicing_time_per_plate;
|
||||||
|
flush_and_exit(CLI_SLICING_TIME_EXCEEDS_LIMIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "found slicing or export error for partplate "<<index+1 << std::endl;
|
BOOST_LOG_TRIVIAL(info) << "found slicing or export error for partplate "<<index+1 << std::endl;
|
||||||
boost::nowide::cerr << ex.what() << std::endl;
|
boost::nowide::cerr << ex.what() << std::endl;
|
||||||
|
|
|
@ -4582,6 +4582,20 @@ CLIActionsConfigDef::CLIActionsConfigDef()
|
||||||
def->cli = "uptodate";
|
def->cli = "uptodate";
|
||||||
def->set_default_value(new ConfigOptionBool(false));
|
def->set_default_value(new ConfigOptionBool(false));
|
||||||
|
|
||||||
|
def = this->add("mtcpp", coInt);
|
||||||
|
def->label = L("mtcpp");
|
||||||
|
def->tooltip = L("max triangle count per plate for slicing.");
|
||||||
|
def->cli = "mtcpp";
|
||||||
|
def->cli_params = "count";
|
||||||
|
def->set_default_value(new ConfigOptionInt(1000000));
|
||||||
|
|
||||||
|
def = this->add("mstpp", coInt);
|
||||||
|
def->label = L("mstpp");
|
||||||
|
def->tooltip = L("max slicing time per plate in seconds.");
|
||||||
|
def->cli = "mstpp";
|
||||||
|
def->cli_params = "time";
|
||||||
|
def->set_default_value(new ConfigOptionInt(300));
|
||||||
|
|
||||||
/*def = this->add("help_fff", coBool);
|
/*def = this->add("help_fff", coBool);
|
||||||
def->label = L("Help (FFF options)");
|
def->label = L("Help (FFF options)");
|
||||||
def->tooltip = L("Show the full list of print/G-code configuration options.");
|
def->tooltip = L("Show the full list of print/G-code configuration options.");
|
||||||
|
|
|
@ -45,7 +45,8 @@
|
||||||
#define CLI_IMPORT_CACHE_NOT_FOUND -55
|
#define CLI_IMPORT_CACHE_NOT_FOUND -55
|
||||||
#define CLI_IMPORT_CACHE_DATA_CAN_NOT_USE -56
|
#define CLI_IMPORT_CACHE_DATA_CAN_NOT_USE -56
|
||||||
#define CLI_IMPORT_CACHE_LOAD_FAILED -57
|
#define CLI_IMPORT_CACHE_LOAD_FAILED -57
|
||||||
|
#define CLI_SLICING_TIME_EXCEEDS_LIMIT -58
|
||||||
|
#define CLI_TRIANGLE_COUNT_EXCEEDS_LIMIT -59
|
||||||
|
|
||||||
#define CLI_SLICING_ERROR -100
|
#define CLI_SLICING_ERROR -100
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue