mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-02 20:51:23 -07:00
ENH: skip_objects: optimize the label_id logic in ModelInstance
Change-Id: Id20fe9b084426036d6cf4f54859655579bec7197 (cherry picked from commit ebb5343eef6aea9e54d11f3d6b98cf11ff941aa5)
This commit is contained in:
parent
8620e3ff85
commit
d385384907
7 changed files with 41 additions and 21 deletions
|
|
@ -1048,7 +1048,7 @@ bool GCode::is_BBL_Printer()
|
|||
return false;
|
||||
}
|
||||
|
||||
void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
|
||||
void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||
{
|
||||
PROFILE_CLEAR();
|
||||
|
||||
|
|
@ -1108,7 +1108,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
|
|||
|
||||
try {
|
||||
m_placeholder_parser_failed_templates.clear();
|
||||
this->_do_export(*print, file, thumbnail_cb, using_identify_id);
|
||||
this->_do_export(*print, file, thumbnail_cb);
|
||||
file.flush();
|
||||
if (file.is_error()) {
|
||||
file.close();
|
||||
|
|
@ -1437,7 +1437,7 @@ static BambuBedType to_bambu_bed_type(BedType type)
|
|||
return bambu_bed_type;
|
||||
}
|
||||
|
||||
void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
|
||||
void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
|
||||
|
|
@ -1530,14 +1530,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
m_label_objects_ids.reserve(print.num_object_instances());
|
||||
for (const PrintObject* print_object : print.objects())
|
||||
for (const PrintInstance& print_instance : print_object->instances())
|
||||
{
|
||||
size_t instance_identify_id;
|
||||
if (using_identify_id && print_instance.model_instance->loaded_id > 0)
|
||||
instance_identify_id = print_instance.model_instance->loaded_id;
|
||||
else
|
||||
instance_identify_id = print_instance.model_instance->id().id;
|
||||
m_label_objects_ids.push_back(instance_identify_id);
|
||||
}
|
||||
m_label_objects_ids.push_back(print_instance.model_instance->get_labeled_id());
|
||||
|
||||
std::sort(m_label_objects_ids.begin(), m_label_objects_ids.end());
|
||||
|
||||
std::string objects_id_list = "; model label id: ";
|
||||
|
|
@ -2473,7 +2467,7 @@ std::vector<GCode::InstanceToPrint> GCode::sort_print_object_instances(
|
|||
const PrintObject *print_object = layers[layer_id].original_object;
|
||||
//const PrintObject *print_object = layers[layer_id].object();
|
||||
if (print_object)
|
||||
out.emplace_back(object_by_extruder, layer_id, *print_object, single_object_instance_idx, print_object->instances()[single_object_instance_idx].model_instance->id().id);
|
||||
out.emplace_back(object_by_extruder, layer_id, *print_object, single_object_instance_idx, print_object->instances()[single_object_instance_idx].model_instance->get_labeled_id());
|
||||
}
|
||||
} else {
|
||||
// Create mapping from PrintObject* to ObjectByExtruder*.
|
||||
|
|
@ -2501,7 +2495,7 @@ std::vector<GCode::InstanceToPrint> GCode::sort_print_object_instances(
|
|||
auto it = std::lower_bound(sorted.begin(), sorted.end(), key);
|
||||
if (it != sorted.end() && it->first == &print_object)
|
||||
// ObjectByExtruder for this PrintObject was found.
|
||||
out.emplace_back(*it->second, it->second - objects_by_extruder.data(), print_object, instance - print_object.instances().data(), instance->model_instance->id().id);
|
||||
out.emplace_back(*it->second, it->second - objects_by_extruder.data(), print_object, instance - print_object.instances().data(), instance->model_instance->get_labeled_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ public:
|
|||
|
||||
// throws std::runtime_exception on error,
|
||||
// throws CanceledException through print->throw_if_canceled().
|
||||
void do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr, bool using_identify_id = false);
|
||||
void do_export(Print* print, const char* path, GCodeProcessorResult* result = nullptr, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
|
||||
|
||||
//BBS: set offset for gcode writer
|
||||
void set_gcode_offset(double x, double y) { m_writer.set_xy_offset(x, y); m_processor.set_xy_offset(x, y);}
|
||||
|
|
@ -277,7 +277,7 @@ private:
|
|||
FILE *f = nullptr;
|
||||
GCodeProcessor &m_processor;
|
||||
};
|
||||
void _do_export(Print &print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id = false);
|
||||
void _do_export(Print &print, GCodeOutputStream &file, ThumbnailsGeneratorCallback thumbnail_cb);
|
||||
|
||||
static std::vector<LayerToPrint> collect_layers_to_print(const PrintObject &object);
|
||||
static std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> collect_layers_to_print(const Print &print);
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ namespace Slic3r {
|
|||
};
|
||||
|
||||
static const std::string& reserved_tag(ETags tag) { return Reserved_Tags[static_cast<unsigned char>(tag)]; }
|
||||
// checks the given gcode for reserved tags and returns true when finding the 1st (which is returned into found_tag)
|
||||
// checks the given gcode for reserved tags and returns true when finding the 1st (which is returned into found_tag)
|
||||
static bool contains_reserved_tag(const std::string& gcode, std::string& found_tag);
|
||||
// checks the given gcode for reserved tags and returns true when finding any
|
||||
// (the first max_count found tags are returned into found_tag)
|
||||
|
|
@ -365,7 +365,7 @@ namespace Slic3r {
|
|||
AxisCoords axis_feedrate; // mm/s
|
||||
AxisCoords abs_axis_feedrate; // mm/s
|
||||
|
||||
//BBS: unit vector of enter speed and exit speed in x-y-z space.
|
||||
//BBS: unit vector of enter speed and exit speed in x-y-z space.
|
||||
//For line move, there are same. For arc move, there are different.
|
||||
Vec3f enter_direction;
|
||||
Vec3f exit_direction;
|
||||
|
|
|
|||
|
|
@ -1227,9 +1227,18 @@ public:
|
|||
ModelInstanceEPrintVolumeState print_volume_state;
|
||||
// Whether or not this instance is printable
|
||||
bool printable;
|
||||
bool use_loaded_id_for_label {false};
|
||||
int arrange_order = 0; // BBS
|
||||
size_t loaded_id = 0; // BBS
|
||||
|
||||
size_t get_labeled_id() const
|
||||
{
|
||||
if (use_loaded_id_for_label && (loaded_id > 0))
|
||||
return loaded_id;
|
||||
else
|
||||
return id().id;
|
||||
}
|
||||
|
||||
ModelObject* get_object() const { return this->object; }
|
||||
|
||||
const Geometry::Transformation& get_transformation() const { return m_transformation; }
|
||||
|
|
|
|||
|
|
@ -1754,7 +1754,7 @@ void Print::process(bool use_cache)
|
|||
// The export_gcode may die for various reasons (fails to process filename_format,
|
||||
// write error into the G-code, cannot execute post-processing scripts).
|
||||
// It is up to the caller to show an error message.
|
||||
std::string Print::export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb, bool using_identify_id)
|
||||
std::string Print::export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||
{
|
||||
// output everything to a G-code file
|
||||
// The following call may die if the filename_format template substitution fails.
|
||||
|
|
@ -1774,7 +1774,7 @@ std::string Print::export_gcode(const std::string& path_template, GCodeProcessor
|
|||
//BBS: compute plate offset for gcode-generator
|
||||
const Vec3d origin = this->get_plate_origin();
|
||||
gcode.set_gcode_offset(origin(0), origin(1));
|
||||
gcode.do_export(this, path.c_str(), result, thumbnail_cb, using_identify_id);
|
||||
gcode.do_export(this, path.c_str(), result, thumbnail_cb);
|
||||
//BBS
|
||||
result->conflict_result = m_conflict_result;
|
||||
return path.c_str();
|
||||
|
|
|
|||
|
|
@ -699,7 +699,7 @@ public:
|
|||
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.
|
||||
// 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, bool using_identify_id = false);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue