1) New methods PrintObject::num_regions() and ::has_region() to make

the code more readable and to highlight where PrintObject::region_volumes
   are actually set and consumed.
2) Replaced Slic3r::clamp() with std::clamp(). They differ in the order
   of their parameters, thus hopefully no new bugs were introduced.
3) Some refactoring of MultiMaterialSegmentation for efficiency.
This commit is contained in:
Vojtech Bubnik 2021-04-22 11:41:26 +02:00
parent 4f950343c8
commit 38bb7d2950
19 changed files with 139 additions and 161 deletions

View file

@ -177,6 +177,8 @@ public:
bool has_brim() const { return this->config().brim_type != btNoBrim && this->config().brim_width.value > 0.; }
size_t num_regions() const { return this->region_volumes.size(); }
bool has_region(size_t i) const { return i < this->region_volumes.size() && ! this->region_volumes[i].empty(); }
// adds region_id, too, if necessary
void add_region_volume(unsigned int region_id, int volume_id, const t_layer_height_range &layer_range) {
@ -471,6 +473,7 @@ public:
return (it == m_objects.end()) ? nullptr : *it;
}
ConstPrintRegionPtrsAdaptor regions() const { return ConstPrintRegionPtrsAdaptor(&m_regions); }
size_t num_regions() const { return m_regions.size(); }
// How many of PrintObject::copies() over all print objects are there?
// If zero, then the print is empty and the print shall not be executed.
unsigned int num_object_instances() const;