mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
ENH: CLI: add time estimation for non-cache slicing
JIRA: XXXX Change-Id: Ifed2d70e8d6355087694df96e413cdbcf792d6d9
This commit is contained in:
parent
04552e4c9b
commit
165bb96e35
6 changed files with 29 additions and 8 deletions
|
@ -145,6 +145,7 @@ std::map<int, std::string> cli_errors = {
|
||||||
typedef struct _sliced_plate_info{
|
typedef struct _sliced_plate_info{
|
||||||
int plate_id{0};
|
int plate_id{0};
|
||||||
size_t sliced_time {0};
|
size_t sliced_time {0};
|
||||||
|
size_t sliced_time_with_cache {0};
|
||||||
size_t triangle_count{0};
|
size_t triangle_count{0};
|
||||||
std::string warning_message;
|
std::string warning_message;
|
||||||
}sliced_plate_info_t;
|
}sliced_plate_info_t;
|
||||||
|
@ -419,6 +420,7 @@ void record_exit_reson(std::string outputdir, int code, int plate_id, std::strin
|
||||||
json plate_json;
|
json plate_json;
|
||||||
plate_json["id"] = sliced_info.sliced_plates[index].plate_id;
|
plate_json["id"] = sliced_info.sliced_plates[index].plate_id;
|
||||||
plate_json["sliced_time"] = sliced_info.sliced_plates[index].sliced_time;
|
plate_json["sliced_time"] = sliced_info.sliced_plates[index].sliced_time;
|
||||||
|
plate_json["sliced_time_with_cache"] = sliced_info.sliced_plates[index].sliced_time_with_cache;
|
||||||
plate_json["triangle_count"] = sliced_info.sliced_plates[index].triangle_count;
|
plate_json["triangle_count"] = sliced_info.sliced_plates[index].triangle_count;
|
||||||
plate_json["warning_message"] = sliced_info.sliced_plates[index].warning_message;
|
plate_json["warning_message"] = sliced_info.sliced_plates[index].warning_message;
|
||||||
j["sliced_plates"].push_back(plate_json);
|
j["sliced_plates"].push_back(plate_json);
|
||||||
|
@ -3101,7 +3103,7 @@ int CLI::run(int argc, char **argv)
|
||||||
|
|
||||||
model.curr_plate_index = index;
|
model.curr_plate_index = index;
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("Plate %1%: pre_check %2%, start")%(index+1)%pre_check;
|
BOOST_LOG_TRIVIAL(info) << boost::format("Plate %1%: pre_check %2%, start")%(index+1)%pre_check;
|
||||||
long long start_time = 0, end_time = 0;
|
long long start_time = 0, end_time = 0, temp_time = 0, time_using_cache = 0;
|
||||||
start_time = (long long)Slic3r::Utils::get_current_time_utc();
|
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);
|
||||||
|
@ -3322,12 +3324,13 @@ int CLI::run(int argc, char **argv)
|
||||||
cli_status_callback(slicing_status);
|
cli_status_callback(slicing_status);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
print->process(true);
|
print->process(nullptr, true);
|
||||||
BOOST_LOG_TRIVIAL(info) << "plate "<< index+1<< ": finished print::process.";
|
BOOST_LOG_TRIVIAL(info) << "plate "<< index+1<< ": finished print::process.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print->process();
|
print->process(&time_using_cache);
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "print::process: first time_using_cache is " << time_using_cache << " secs.";
|
||||||
}
|
}
|
||||||
if (printer_technology == ptFFF) {
|
if (printer_technology == ptFFF) {
|
||||||
std::string conflict_result = print_fff->get_conflict_string();
|
std::string conflict_result = print_fff->get_conflict_string();
|
||||||
|
@ -3379,7 +3382,11 @@ int CLI::run(int argc, char **argv)
|
||||||
part_plate->set_tmp_gcode_path(outfile);
|
part_plate->set_tmp_gcode_path(outfile);
|
||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl;
|
BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl;
|
||||||
|
temp_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||||
outfile = print_fff->export_gcode(outfile, gcode_result, nullptr);
|
outfile = print_fff->export_gcode(outfile, gcode_result, nullptr);
|
||||||
|
time_using_cache = time_using_cache + ((long long)Slic3r::Utils::get_current_time_utc() - temp_time);
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "export_gcode finished: time_using_cache update to " << time_using_cache << " secs.";
|
||||||
|
|
||||||
//outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile);
|
//outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile);
|
||||||
//m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
|
//m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
|
||||||
}/* else {
|
}/* else {
|
||||||
|
@ -3422,6 +3429,7 @@ int CLI::run(int argc, char **argv)
|
||||||
}
|
}
|
||||||
end_time = (long long)Slic3r::Utils::get_current_time_utc();
|
end_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||||
sliced_plate_info.sliced_time = end_time - start_time;
|
sliced_plate_info.sliced_time = end_time - start_time;
|
||||||
|
sliced_plate_info.sliced_time_with_cache = time_using_cache;
|
||||||
|
|
||||||
if (max_slicing_time_per_plate != 0) {
|
if (max_slicing_time_per_plate != 0) {
|
||||||
long long time_cost = end_time - start_time;
|
long long time_cost = end_time - start_time;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "ShortestPath.hpp"
|
#include "ShortestPath.hpp"
|
||||||
#include "SupportMaterial.hpp"
|
#include "SupportMaterial.hpp"
|
||||||
#include "Thread.hpp"
|
#include "Thread.hpp"
|
||||||
|
#include "Time.hpp"
|
||||||
#include "GCode.hpp"
|
#include "GCode.hpp"
|
||||||
#include "GCode/WipeTower.hpp"
|
#include "GCode/WipeTower.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
@ -1479,8 +1480,12 @@ std::map<ObjectID, unsigned int> getObjectExtruderMap(const Print& print) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slicing process, running at a background thread.
|
// Slicing process, running at a background thread.
|
||||||
void Print::process(bool use_cache)
|
void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||||
{
|
{
|
||||||
|
long long start_time = 0, end_time = 0;
|
||||||
|
if (time_cost_with_cache)
|
||||||
|
*time_cost_with_cache = 0;
|
||||||
|
|
||||||
name_tbb_thread_pool_threads_set_locale();
|
name_tbb_thread_pool_threads_set_locale();
|
||||||
|
|
||||||
//compute the PrintObject with the same geometries
|
//compute the PrintObject with the same geometries
|
||||||
|
@ -1680,6 +1685,9 @@ void Print::process(bool use_cache)
|
||||||
if (this->set_started(psSkirtBrim)) {
|
if (this->set_started(psSkirtBrim)) {
|
||||||
this->set_status(70, L("Generating skirt & brim"));
|
this->set_status(70, L("Generating skirt & brim"));
|
||||||
|
|
||||||
|
if (time_cost_with_cache)
|
||||||
|
start_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||||
|
|
||||||
m_skirt.clear();
|
m_skirt.clear();
|
||||||
m_skirt_convex_hull.clear();
|
m_skirt_convex_hull.clear();
|
||||||
m_first_layer_convex_hull.points.clear();
|
m_first_layer_convex_hull.points.clear();
|
||||||
|
@ -1764,6 +1772,11 @@ void Print::process(bool use_cache)
|
||||||
|
|
||||||
this->finalize_first_layer_convex_hull();
|
this->finalize_first_layer_convex_hull();
|
||||||
this->set_done(psSkirtBrim);
|
this->set_done(psSkirtBrim);
|
||||||
|
|
||||||
|
if (time_cost_with_cache) {
|
||||||
|
end_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||||
|
*time_cost_with_cache = *time_cost_with_cache + end_time - start_time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//BBS
|
//BBS
|
||||||
for (PrintObject *obj : m_objects) {
|
for (PrintObject *obj : m_objects) {
|
||||||
|
|
|
@ -698,7 +698,7 @@ public:
|
||||||
|
|
||||||
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
||||||
|
|
||||||
void process(bool use_cache = false) override;
|
void process(long long *time_cost_with_cache = nullptr, bool use_cache = false) override;
|
||||||
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
||||||
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
|
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
|
||||||
std::string export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
|
std::string export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
|
||||||
|
|
|
@ -422,7 +422,7 @@ public:
|
||||||
// After calling the apply() function, call set_task() to limit the task to be processed by process().
|
// After calling the apply() function, call set_task() to limit the task to be processed by process().
|
||||||
virtual void set_task(const TaskParams ¶ms) {}
|
virtual void set_task(const TaskParams ¶ms) {}
|
||||||
// Perform the calculation. This is the only method that is to be called at a worker thread.
|
// Perform the calculation. This is the only method that is to be called at a worker thread.
|
||||||
virtual void process(bool use_cache = false) = 0;
|
virtual void process(long long *time_cost_with_cache = nullptr, bool use_cache = false) = 0;
|
||||||
virtual int export_cached_data(const std::string& dir_path, bool with_space=false) { return 0;}
|
virtual int export_cached_data(const std::string& dir_path, bool with_space=false) { return 0;}
|
||||||
virtual int load_cached_data(const std::string& directory) { return 0;}
|
virtual int load_cached_data(const std::string& directory) { return 0;}
|
||||||
// Clean up after process() finished, either with success, error or if canceled.
|
// Clean up after process() finished, either with success, error or if canceled.
|
||||||
|
|
|
@ -686,7 +686,7 @@ bool SLAPrint::invalidate_step(SLAPrintStep step)
|
||||||
return invalidated;
|
return invalidated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SLAPrint::process(bool use_cache)
|
void SLAPrint::process(long long *time_cost_with_cache, bool use_cache)
|
||||||
{
|
{
|
||||||
if (m_objects.empty())
|
if (m_objects.empty())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -451,7 +451,7 @@ public:
|
||||||
std::vector<ObjectID> print_object_ids() const override;
|
std::vector<ObjectID> print_object_ids() const override;
|
||||||
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
||||||
void set_task(const TaskParams ¶ms) override;
|
void set_task(const TaskParams ¶ms) override;
|
||||||
void process(bool use_cache = false) override;
|
void process(long long *time_cost_with_cache = nullptr, bool use_cache = false) override;
|
||||||
void finalize() override;
|
void finalize() override;
|
||||||
// Returns true if an object step is done on all objects and there's at least one object.
|
// Returns true if an object step is done on all objects and there's at least one object.
|
||||||
bool is_step_done(SLAPrintObjectStep step) const;
|
bool is_step_done(SLAPrintObjectStep step) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue