Fixed MMU segmentation for multi-volume objects.

MMU segmentation no longer works directly on lslices, instead of it works on custom merged regions. So lslices in PrintObject are no longer overwritten because of MMU segmentation.
All regions are scaled by SCALED_EPSILON before merging and shrunk back by SCALED_EPSILON after merging. That fixed issues with multi-volume objects when very close regions weren't merged.
Also, small expolygons and holes are filtered out that fixed missing segmentation at the boundary of two volumes in the case of multi-volume objects.
This commit is contained in:
Lukáš Hejl 2021-05-03 20:37:14 +02:00
parent 0a8a3f6d8c
commit 168b4afbc2
4 changed files with 42 additions and 17 deletions

View file

@ -1906,15 +1906,6 @@ void PrintObject::_slice(const std::vector<coordf_t> &layer_height_profile)
// --------------------MMU_SEGMENTATION_BEGIN----------------------
// Temporary fix for not assigned lslices
for(size_t layer_idx = 0; layer_idx < m_layers.size(); layer_idx += 1) {
ExPolygons ex_polygons;
for (LayerRegion *region : this->m_layers[layer_idx]->regions())
for (const Surface &surface : region->slices.surfaces)
ex_polygons.emplace_back(surface.expolygon);
this->m_layers[layer_idx]->lslices = union_ex(ex_polygons);
}
size_t region_count_before_change = this->num_regions();
std::vector<std::vector<std::pair<ExPolygon, size_t>>> segmented_regions = multi_material_segmentation_by_painting(*this);
// Skip region with default extruder