ENH: slicing: add cache data load/export for slicing

Change-Id: I88b7c79b6f79ec6bed0f829316b67310cac99b44
(cherry picked from commit 67c1d2e8dd459cc4450ce580632f01e25db038ac)
This commit is contained in:
lane.wei 2022-11-22 15:22:47 +08:00 committed by Lane.Wei
parent 2ffa56633c
commit c3abc64b61
13 changed files with 1471 additions and 192 deletions

View file

@ -91,29 +91,6 @@ using namespace Slic3r;
std::string message; std::string message;
}error_message;*/ }error_message;*/
#define CLI_SUCCESS 0
#define CLI_ENVIRONMENT_ERROR -1
#define CLI_INVALID_PARAMS -2
#define CLI_FILE_NOTFOUND -3
#define CLI_FILELIST_INVALID_ORDER -4
#define CLI_CONFIG_FILE_ERROR -5
#define CLI_DATA_FILE_ERROR -6
#define CLI_INVALID_PRINTER_TECH -7
#define CLI_UNSUPPORTED_OPERATION -8
#define CLI_COPY_OBJECTS_ERROR -9
#define CLI_SCALE_TO_FIT_ERROR -10
#define CLI_EXPORT_STL_ERROR -11
#define CLI_EXPORT_OBJ_ERROR -12
#define CLI_EXPORT_3MF_ERROR -13
#define CLI_NO_SUITABLE_OBJECTS -50
#define CLI_VALIDATE_ERROR -51
#define CLI_OBJECTS_PARTLY_INSIDE -52
#define CLI_SLICING_ERROR -100
std::map<int, std::string> cli_errors = { std::map<int, std::string> cli_errors = {
{CLI_SUCCESS, "Success"}, {CLI_SUCCESS, "Success"},
@ -130,9 +107,15 @@ std::map<int, std::string> cli_errors = {
{CLI_EXPORT_STL_ERROR, "Export stl error"}, {CLI_EXPORT_STL_ERROR, "Export stl error"},
{CLI_EXPORT_OBJ_ERROR, "Export obj error"}, {CLI_EXPORT_OBJ_ERROR, "Export obj error"},
{CLI_EXPORT_3MF_ERROR, "Export 3mf error"}, {CLI_EXPORT_3MF_ERROR, "Export 3mf error"},
{CLI_OUT_OF_MEMORY, "Out of memory"},
{CLI_NO_SUITABLE_OBJECTS, "Found no objects in print volume to slice"}, {CLI_NO_SUITABLE_OBJECTS, "Found no objects in print volume to slice"},
{CLI_VALIDATE_ERROR, "Validate print error"}, {CLI_VALIDATE_ERROR, "Validate print error"},
{CLI_OBJECTS_PARTLY_INSIDE, "Objects partly inside"}, {CLI_OBJECTS_PARTLY_INSIDE, "Objects partly inside"},
{CLI_EXPORT_CACHE_DIRECTORY_CREATE_FAILED, "Objects partly inside"},
{CLI_EXPORT_CACHE_WRITE_FAILED, "export cached slicedata failed"},
{CLI_IMPORT_CACHE_NOT_FOUND, "cached slicedata can not be found"},
{CLI_IMPORT_CACHE_DATA_CAN_NOT_USE, "cached slicedata can not be used"},
{CLI_IMPORT_CACHE_LOAD_FAILED, "load cached slicedata failed"},
{CLI_SLICING_ERROR, "Slice error"} {CLI_SLICING_ERROR, "Slice error"}
}; };
@ -374,12 +357,12 @@ int CLI::run(int argc, char **argv)
int debug_argc = 7; int debug_argc = 7;
char *debug_argv[] = { char *debug_argv[] = {
"E:\work\projects\bambu_release\bamboo_slicer\build_debug\src\Debug\bambu-studio.exe", "E:\work\projects\bambu_release\bamboo_slicer\build_debug\src\Debug\bambu-studio.exe",
"--load-slicedata",
"cached_data",
"--slice", "--slice",
"2", "0",
"--export-3mf=output.3mf", "--export-3mf=output.3mf",
"--load-filaments", "test.3mf"
"GFSA05.json;GFSA04.json;;GFSA05.json;GFSL23.json",
"majiang.3mf"
}; };
if (! this->setup(debug_argc, debug_argv))*/ if (! this->setup(debug_argc, debug_argv))*/
if (!this->setup(argc, argv)) if (!this->setup(argc, argv))
@ -1345,8 +1328,8 @@ int CLI::run(int argc, char **argv)
o->ensure_on_bed(); o->ensure_on_bed();
// loop through action options // loop through action options
bool export_to_3mf = false; bool export_to_3mf = false, load_slicedata = false, export_slicedata = false, export_slicedata_error = false;
std::string export_3mf_file; 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;
for (auto const &opt_key : m_actions) { for (auto const &opt_key : m_actions) {
@ -1361,6 +1344,13 @@ int CLI::run(int argc, char **argv)
std::string pipe_name = m_config.option<ConfigOptionString>("pipe")->value; std::string pipe_name = m_config.option<ConfigOptionString>("pipe")->value;
g_cli_callback_mgr.start(pipe_name); g_cli_callback_mgr.start(pipe_name);
#endif #endif
} else if (opt_key == "load_slicedata") {
load_slicedata = true;
load_slice_data_dir = m_config.opt_string(opt_key);
if (export_slicedata) {
BOOST_LOG_TRIVIAL(error) << "should not set load_slicedata and export_slicedata together." << std::endl;
flush_and_exit(CLI_INVALID_PARAMS);
}
} else if (opt_key == "export_settings") { } else if (opt_key == "export_settings") {
//FIXME check for mixing the FFF / SLA parameters. //FIXME check for mixing the FFF / SLA parameters.
// or better save fff_print_config vs. sla_print_config // or better save fff_print_config vs. sla_print_config
@ -1377,7 +1367,7 @@ int CLI::run(int argc, char **argv)
model.add_default_instances(); model.add_default_instances();
if (! this->export_models(IO::STL)) if (! this->export_models(IO::STL))
flush_and_exit(CLI_EXPORT_STL_ERROR); flush_and_exit(CLI_EXPORT_STL_ERROR);
} else if (opt_key == "expor1t_obj") { } else if (opt_key == "export_obj") {
for (auto &model : m_models) for (auto &model : m_models)
model.add_default_instances(); model.add_default_instances();
if (! this->export_models(IO::OBJ)) if (! this->export_models(IO::OBJ))
@ -1389,6 +1379,13 @@ int CLI::run(int argc, char **argv)
export_to_3mf = true; export_to_3mf = true;
export_3mf_file = m_config.opt_string(opt_key); export_3mf_file = m_config.opt_string(opt_key);
//} else if (opt_key == "export_gcode" || opt_key == "export_sla" || opt_key == "slice") { //} else if (opt_key == "export_gcode" || opt_key == "export_sla" || opt_key == "slice") {
} else if (opt_key == "export_slicedata") {
export_slicedata = true;
export_slice_data_dir = m_config.opt_string(opt_key);
if (load_slicedata) {
BOOST_LOG_TRIVIAL(error) << "should not set load_slicedata and export_slicedata together." << std::endl;
flush_and_exit(CLI_INVALID_PARAMS);
}
} else if (opt_key == "slice") { } else if (opt_key == "slice") {
//BBS: slice 0 means all plates, i means plate i; //BBS: slice 0 means all plates, i means plate i;
plate_to_slice = m_config.option<ConfigOptionInt>("slice")->value; plate_to_slice = m_config.option<ConfigOptionInt>("slice")->value;
@ -1530,7 +1527,23 @@ int CLI::run(int argc, char **argv)
} }
} }
#endif #endif
if (load_slicedata) {
std::string plate_dir = load_slice_data_dir+"/"+std::to_string(index+1);
int ret = print->load_cached_data(plate_dir);
if (ret) {
BOOST_LOG_TRIVIAL(warning) << "plate "<< index+1<< ": load Slicing data error, ret=" << ret;
BOOST_LOG_TRIVIAL(warning) << "plate "<< index+1<< ": switch normal slicing";
print->process(); print->process();
}
else {
BOOST_LOG_TRIVIAL(info) << "plate "<< index+1<< ": load cached data success, go on.";
print->process(true);
BOOST_LOG_TRIVIAL(info) << "plate "<< index+1<< ": finished print::process.";
}
}
else {
print->process();
}
if (printer_technology == ptFFF) { if (printer_technology == ptFFF) {
// The outfile is processed by a PlaceholderParser. // The outfile is processed by a PlaceholderParser.
//outfile = part_plate->get_tmp_gcode_path(); //outfile = part_plate->get_tmp_gcode_path();
@ -1569,6 +1582,18 @@ int CLI::run(int argc, char **argv)
cli_status_callback(slicing_status); cli_status_callback(slicing_status);
} }
#endif #endif
if (export_slicedata) {
BOOST_LOG_TRIVIAL(info) << "plate "<< index+1<< ":will export Slicing data to " << export_slice_data_dir;
std::string plate_dir = export_slice_data_dir+"/"+std::to_string(index+1);
bool with_space = (get_logging_level() >= 4)?true:false;
int ret = print->export_cached_data(plate_dir, with_space);
if (ret) {
BOOST_LOG_TRIVIAL(error) << "plate "<< index+1<< ": export Slicing data error, ret=" << ret;
export_slicedata_error = true;
if (fs::exists(plate_dir))
fs::remove_all(plate_dir);
}
}
} 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;
@ -2037,9 +2062,10 @@ bool CLI::setup(int argc, char **argv)
#if !BBL_RELEASE_TO_PUBLIC #if !BBL_RELEASE_TO_PUBLIC
{ {
const ConfigOptionInt *opt_loglevel = m_config.opt<ConfigOptionInt>("debug"); const ConfigOptionInt *opt_loglevel = m_config.opt<ConfigOptionInt>("debug");
if (opt_loglevel != 0) if (opt_loglevel != 0) {
set_logging_level(opt_loglevel->value); set_logging_level(opt_loglevel->value);
} }
}
#endif #endif
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet. //FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.

View file

@ -137,6 +137,7 @@ public:
// Height of the extrusion, used for visualization purposes. // Height of the extrusion, used for visualization purposes.
float height; float height;
ExtrusionPath() : mm3_per_mm(-1), width(-1), height(-1), m_role(erNone), m_no_extrusion(false) {}
ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), m_role(role), m_no_extrusion(false) {} ExtrusionPath(ExtrusionRole role) : mm3_per_mm(-1), width(-1), height(-1), m_role(role), m_no_extrusion(false) {}
ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height, bool no_extrusion = false) : mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role), m_no_extrusion(no_extrusion) {} ExtrusionPath(ExtrusionRole role, double mm3_per_mm, float width, float height, bool no_extrusion = false) : mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role), m_no_extrusion(no_extrusion) {}
ExtrusionPath(int overhang_degree, int curve_degree, ExtrusionRole role, double mm3_per_mm, float width, float height) : overhang_degree(overhang_degree), curve_degree(curve_degree), mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role) {} ExtrusionPath(int overhang_degree, int curve_degree, ExtrusionRole role, double mm3_per_mm, float width, float height) : overhang_degree(overhang_degree), curve_degree(curve_degree), mm3_per_mm(mm3_per_mm), width(width), height(height), m_role(role) {}
@ -225,6 +226,8 @@ public:
void simplify_by_fitting_arc(double tolerance); void simplify_by_fitting_arc(double tolerance);
//BBS: //BBS:
bool is_force_no_extrusion() const { return m_no_extrusion; } bool is_force_no_extrusion() const { return m_no_extrusion; }
void set_force_no_extrusion(bool no_extrusion) { m_no_extrusion = no_extrusion; }
void set_extrusion_role(ExtrusionRole extrusion_role) { m_role = extrusion_role; }
private: private:
void _inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const; void _inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const;
@ -329,6 +332,7 @@ public:
bool has_overhang_point(const Point &point) const; bool has_overhang_point(const Point &point) const;
ExtrusionRole role() const override { return this->paths.empty() ? erNone : this->paths.front().role(); } ExtrusionRole role() const override { return this->paths.empty() ? erNone : this->paths.front().role(); }
ExtrusionLoopRole loop_role() const { return m_loop_role; } ExtrusionLoopRole loop_role() const { return m_loop_role; }
void set_loop_role(ExtrusionLoopRole role) { m_loop_role = role; }
// Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion width. // Produce a list of 2D polygons covered by the extruded paths, offsetted by the extrusion width.
// Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps. // Increase the offset by scaled_epsilon to achieve an overlap, so a union will produce no gaps.
void polygons_covered_by_width(Polygons &out, const float scaled_epsilon) const override; void polygons_covered_by_width(Polygons &out, const float scaled_epsilon) const override;

View file

@ -245,6 +245,7 @@ static constexpr const char* PATTERN_FILE_ATTR = "pattern_file";
static constexpr const char* PATTERN_BBOX_FILE_ATTR = "pattern_bbox_file"; static constexpr const char* PATTERN_BBOX_FILE_ATTR = "pattern_bbox_file";
static constexpr const char* OBJECT_ID_ATTR = "object_id"; static constexpr const char* OBJECT_ID_ATTR = "object_id";
static constexpr const char* INSTANCEID_ATTR = "instance_id"; static constexpr const char* INSTANCEID_ATTR = "instance_id";
static constexpr const char* ARRANGE_ORDER_ATTR = "arrange_order";
static constexpr const char* PLATERID_ATTR = "plater_id"; static constexpr const char* PLATERID_ATTR = "plater_id";
static constexpr const char* PLATE_IDX_ATTR = "index"; static constexpr const char* PLATE_IDX_ATTR = "index";
static constexpr const char* SLICE_PREDICTION_ATTR = "prediction"; static constexpr const char* SLICE_PREDICTION_ATTR = "prediction";
@ -604,6 +605,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
{ {
int object_id; int object_id;
int instance_id; int instance_id;
int arrange_order;
}; };
struct Instance struct Instance
@ -1123,6 +1125,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
m_plater_data.clear(); m_plater_data.clear();
m_curr_instance.object_id = -1; m_curr_instance.object_id = -1;
m_curr_instance.instance_id = -1; m_curr_instance.instance_id = -1;
m_curr_instance.arrange_order = 0;
clear_errors(); clear_errors();
// restore // restore
@ -1570,7 +1573,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
return false; return false;
} }
if (current_plate_data) { if (current_plate_data) {
std::map<int, int>::iterator it = current_plate_data->obj_inst_map.find(object.first.second); std::map<int, std::pair<int, int>>::iterator it = current_plate_data->obj_inst_map.find(object.first.second);
if (it == current_plate_data->obj_inst_map.end()) { if (it == current_plate_data->obj_inst_map.end()) {
//not in current plate, skip //not in current plate, skip
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", could not find object %1% in plate %2%, skip it\n")%object.first.second %plate_id; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", could not find object %1% in plate %2%, skip it\n")%object.first.second %plate_id;
@ -1769,8 +1772,46 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
plate_data_list[it->first-1]->pattern_file = (m_load_restore || it->second->pattern_file.empty()) ? it->second->pattern_file : m_backup_path + "/" + it->second->pattern_file; plate_data_list[it->first-1]->pattern_file = (m_load_restore || it->second->pattern_file.empty()) ? it->second->pattern_file : m_backup_path + "/" + it->second->pattern_file;
plate_data_list[it->first-1]->pattern_bbox_file = (m_load_restore || it->second->pattern_bbox_file.empty()) ? it->second->pattern_bbox_file : m_backup_path + "/" + it->second->pattern_bbox_file; plate_data_list[it->first-1]->pattern_bbox_file = (m_load_restore || it->second->pattern_bbox_file.empty()) ? it->second->pattern_bbox_file : m_backup_path + "/" + it->second->pattern_bbox_file;
plate_data_list[it->first-1]->config = it->second->config; plate_data_list[it->first-1]->config = it->second->config;
current_plate_data = plate_data_list[it->first - 1];
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", plate %1%, thumbnail_file=%2%")%it->first %plate_data_list[it->first-1]->thumbnail_file; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format(", plate %1%, thumbnail_file=%2%")%it->first %plate_data_list[it->first-1]->thumbnail_file;
it++; it++;
//update the arrange order
std::map<int, std::pair<int, int>>::iterator map_it = current_plate_data->obj_inst_map.begin();
while (map_it != current_plate_data->obj_inst_map.end()) {
int obj_index, obj_id = map_it->first, inst_index = map_it->second.first;
IndexToPathMap::iterator index_iter = m_index_paths.find(obj_id);
if (index_iter == m_index_paths.end()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ":" << __LINE__
<< boost::format(", can not find object from plate's obj_map, id=%1%, skip this object")%obj_id;
map_it++;
continue;
}
Id temp_id = std::make_pair(index_iter->second, index_iter->first);
IdToModelObjectMap::iterator object_item = m_objects.find(temp_id);
if (object_item == m_objects.end()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ":" << __LINE__
<< boost::format(", can not find object from plate's obj_map, ID <%1%, %2%>, skip this object")%index_iter->second %index_iter->first;
map_it++;
continue;
}
obj_index = object_item->second;
if (obj_index >= m_model->objects.size()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ":" << __LINE__ << boost::format("invalid object id %1%\n")%obj_index;
map_it++;
continue;
}
ModelObject* obj = m_model->objects[obj_index];
if (inst_index >= obj->instances.size()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ":" << __LINE__ << boost::format("invalid instance id %1%\n")%inst_index;
map_it++;
continue;
}
ModelInstance* inst = obj->instances[inst_index];
inst->arrange_order = map_it->second.second;
map_it++;
}
} }
if ((plate_id > 0) && (plate_id <= m_plater_data.size())) { if ((plate_id > 0) && (plate_id <= m_plater_data.size())) {
@ -3417,6 +3458,10 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
{ {
m_curr_instance.instance_id = atoi(value.c_str()); m_curr_instance.instance_id = atoi(value.c_str());
} }
else if (key == ARRANGE_ORDER_ATTR)
{
m_curr_instance.arrange_order = atoi(value.c_str());
}
else if (key == OBJECT_ID_ATTR) else if (key == OBJECT_ID_ATTR)
{ {
m_curr_instance.object_id = atoi(value.c_str()); m_curr_instance.object_id = atoi(value.c_str());
@ -3570,11 +3615,13 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
//add_error("invalid object id/instance id"); //add_error("invalid object id/instance id");
//skip this instance //skip this instance
m_curr_instance.object_id = m_curr_instance.instance_id = -1; m_curr_instance.object_id = m_curr_instance.instance_id = -1;
m_curr_instance.arrange_order = 0;
return true; return true;
} }
m_curr_plater->obj_inst_map.emplace(m_curr_instance.object_id, m_curr_instance.instance_id); m_curr_plater->obj_inst_map.emplace(m_curr_instance.object_id, std::make_pair(m_curr_instance.instance_id, m_curr_instance.arrange_order));
m_curr_instance.object_id = m_curr_instance.instance_id = -1; m_curr_instance.object_id = m_curr_instance.instance_id = -1;
m_curr_instance.arrange_order = 0;
return true; return true;
} }
@ -6360,14 +6407,32 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << INSTANCE_TAG << ">\n"; stream << " <" << INSTANCE_TAG << ">\n";
int obj_id = plate_data->objects_and_instances[j].first; int obj_id = plate_data->objects_and_instances[j].first;
int inst_id = plate_data->objects_and_instances[j].second; int inst_id = plate_data->objects_and_instances[j].second;
if (m_skip_static) { int arrange_o = 0;
obj_id = model.objects[obj_id]->get_backup_id(); ModelObject* obj = NULL;
ModelInstance* inst = NULL;
if (obj_id >= model.objects.size()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ":" << __LINE__ << boost::format("invalid object id %1%\n")%obj_id;
}
else
obj = model.objects[obj_id];
if (obj && (inst_id >= obj->instances.size())) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ":" << __LINE__ << boost::format("invalid instance id %1%\n")%inst_id;
}
else if (obj){
inst = obj->instances[inst_id];
arrange_o = inst->arrange_order;
}
if (m_skip_static && obj) {
obj_id = obj->get_backup_id();
} else { } else {
//inst_id = convert_instance_id_to_resource_id(model, obj_id, inst_id); //inst_id = convert_instance_id_to_resource_id(model, obj_id, inst_id);
obj_id = convert_instance_id_to_resource_id(model, obj_id, 0); obj_id = convert_instance_id_to_resource_id(model, obj_id, 0);
} }
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OBJECT_ID_ATTR << "\" " << VALUE_ATTR << "=\"" << obj_id << "\"/>\n"; stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OBJECT_ID_ATTR << "\" " << VALUE_ATTR << "=\"" << obj_id << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << INSTANCEID_ATTR << "\" " << VALUE_ATTR << "=\"" << inst_id << "\"/>\n"; stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << INSTANCEID_ATTR << "\" " << VALUE_ATTR << "=\"" << inst_id << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << ARRANGE_ORDER_ATTR << "\" " << VALUE_ATTR << "=\"" << arrange_o << "\"/>\n";
stream << " </" << INSTANCE_TAG << ">\n"; stream << " </" << INSTANCE_TAG << ">\n";
} }
} }

View file

@ -57,7 +57,7 @@ struct PlateData
int plate_index; int plate_index;
std::vector<std::pair<int, int>> objects_and_instances; std::vector<std::pair<int, int>> objects_and_instances;
std::map<int, int> obj_inst_map; std::map<int, std::pair<int, int>> obj_inst_map;
std::string gcode_file; std::string gcode_file;
std::string gcode_file_md5; std::string gcode_file_md5;
std::string thumbnail_file; std::string thumbnail_file;

File diff suppressed because it is too large Load diff

View file

@ -628,10 +628,13 @@ public:
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override; ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
void process() override; void process(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);
//return 0 means successful
int export_cached_data(const std::string& dir_path, bool with_space=false);
int load_cached_data(const std::string& directory);
// methods for handling state // methods for handling state
bool is_step_done(PrintStep step) const { return Inherited::is_step_done(step); } bool is_step_done(PrintStep step) const { return Inherited::is_step_done(step); }
@ -788,6 +791,7 @@ public:
static float min_skirt_length; static float min_skirt_length;
}; };
} /* slic3r_Print_hpp_ */ } /* slic3r_Print_hpp_ */
#endif #endif

View file

@ -419,7 +419,9 @@ 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 &params) {} virtual void set_task(const TaskParams &params) {}
// 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() = 0; virtual void process(bool use_cache = false) = 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;}
// Clean up after process() finished, either with success, error or if canceled. // Clean up after process() finished, either with success, error or if canceled.
// The adjustments on the Print / PrintObject data due to set_task() are to be reverted here. // The adjustments on the Print / PrintObject data due to set_task() are to be reverted here.
virtual void finalize() {} virtual void finalize() {}

View file

@ -4333,6 +4333,18 @@ CLIActionsConfigDef::CLIActionsConfigDef()
def->cli_params = "filename.3mf"; def->cli_params = "filename.3mf";
def->set_default_value(new ConfigOptionString("output.3mf")); def->set_default_value(new ConfigOptionString("output.3mf"));
def = this->add("export_slicedata", coString);
def->label = L("Export slicing data");
def->tooltip = L("Export slicing data to a folder.");
def->cli_params = "slicing_data_directory";
def->set_default_value(new ConfigOptionString("cached_data"));
def = this->add("load_slicedata", coStrings);
def->label = L("Load slicing data");
def->tooltip = L("Load cached slicing data from directory");
def->cli_params = "slicing_data_directory";
def->set_default_value(new ConfigOptionString("cached_data"));
/*def = this->add("export_amf", coBool); /*def = this->add("export_amf", coBool);
def->label = L("Export AMF"); def->label = L("Export AMF");
def->tooltip = L("Export the model(s) as AMF."); def->tooltip = L("Export the model(s) as AMF.");

View file

@ -686,7 +686,7 @@ bool SLAPrint::invalidate_step(SLAPrintStep step)
return invalidated; return invalidated;
} }
void SLAPrint::process() void SLAPrint::process(bool use_cache)
{ {
if (m_objects.empty()) if (m_objects.empty())
return; return;

View file

@ -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 &params) override; void set_task(const TaskParams &params) override;
void process() override; void process(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;

View file

@ -40,6 +40,10 @@ public:
double bridge_angle; // in radians, ccw, 0 = East, only 0+ (negative means undefined) double bridge_angle; // in radians, ccw, 0 = East, only 0+ (negative means undefined)
unsigned short extra_perimeters; unsigned short extra_perimeters;
Surface(SurfaceType _surface_type = stInternal)
: surface_type(_surface_type),
thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0)
{};
Surface(const Slic3r::Surface &rhs) Surface(const Slic3r::Surface &rhs)
: surface_type(rhs.surface_type), expolygon(rhs.expolygon), : surface_type(rhs.surface_type), expolygon(rhs.expolygon),
thickness(rhs.thickness), thickness_layers(rhs.thickness_layers), thickness(rhs.thickness), thickness_layers(rhs.thickness_layers),

View file

@ -13,6 +13,38 @@
#include "libslic3r.h" #include "libslic3r.h"
//define CLI errors
#define CLI_SUCCESS 0
#define CLI_ENVIRONMENT_ERROR -1
#define CLI_INVALID_PARAMS -2
#define CLI_FILE_NOTFOUND -3
#define CLI_FILELIST_INVALID_ORDER -4
#define CLI_CONFIG_FILE_ERROR -5
#define CLI_DATA_FILE_ERROR -6
#define CLI_INVALID_PRINTER_TECH -7
#define CLI_UNSUPPORTED_OPERATION -8
#define CLI_COPY_OBJECTS_ERROR -9
#define CLI_SCALE_TO_FIT_ERROR -10
#define CLI_EXPORT_STL_ERROR -11
#define CLI_EXPORT_OBJ_ERROR -12
#define CLI_EXPORT_3MF_ERROR -13
#define CLI_OUT_OF_MEMORY -14
#define CLI_NO_SUITABLE_OBJECTS -50
#define CLI_VALIDATE_ERROR -51
#define CLI_OBJECTS_PARTLY_INSIDE -52
#define CLI_EXPORT_CACHE_DIRECTORY_CREATE_FAILED -53
#define CLI_EXPORT_CACHE_WRITE_FAILED -54
#define CLI_IMPORT_CACHE_NOT_FOUND -55
#define CLI_IMPORT_CACHE_DATA_CAN_NOT_USE -56
#define CLI_IMPORT_CACHE_LOAD_FAILED -57
#define CLI_SLICING_ERROR -100
namespace boost { namespace filesystem { class directory_entry; }} namespace boost { namespace filesystem { class directory_entry; }}
namespace Slic3r { namespace Slic3r {