mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 20:57:53 -06:00
Parallelization of regions merging for MMU segmentation.
This commit is contained in:
parent
2e9f0d6eaf
commit
5bfdaa7ac8
1 changed files with 21 additions and 19 deletions
|
@ -1360,25 +1360,27 @@ std::vector<std::vector<std::pair<ExPolygon, size_t>>> multi_material_segmentati
|
||||||
std::vector<Polygons> input_polygons(layers.size());
|
std::vector<Polygons> input_polygons(layers.size());
|
||||||
|
|
||||||
// Merge all regions and remove small holes
|
// Merge all regions and remove small holes
|
||||||
for(size_t layer_idx = 0; layer_idx < layers.size(); layer_idx += 1) {
|
tbb::parallel_for(tbb::blocked_range<size_t>(0, layers.size()), [&](const tbb::blocked_range<size_t> &range) {
|
||||||
ExPolygons ex_polygons;
|
for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) {
|
||||||
for (LayerRegion *region : layers[layer_idx]->regions())
|
ExPolygons ex_polygons;
|
||||||
for (const Surface &surface : region->slices.surfaces)
|
for (LayerRegion *region : layers[layer_idx]->regions())
|
||||||
Slic3r::append(ex_polygons, offset_ex(surface.expolygon, SCALED_EPSILON));
|
for (const Surface &surface : region->slices.surfaces)
|
||||||
// All expolygons are expanded by SCALED_EPSILON, merged, and then shrunk again by SCALED_EPSILON
|
Slic3r::append(ex_polygons, offset_ex(surface.expolygon, SCALED_EPSILON));
|
||||||
// to ensure that very close polygons will be merged.
|
// All expolygons are expanded by SCALED_EPSILON, merged, and then shrunk again by SCALED_EPSILON
|
||||||
ex_polygons = union_ex(ex_polygons);
|
// to ensure that very close polygons will be merged.
|
||||||
// Remove all expolygons and holes with an area less than 0.01mm^2
|
ex_polygons = union_ex(ex_polygons);
|
||||||
remove_small_and_small_holes(ex_polygons, Slic3r::sqr(scale_(0.1f)));
|
// Remove all expolygons and holes with an area less than 0.01mm^2
|
||||||
// Occasionally, some input polygons contained self-intersections that caused problems with Voronoi diagrams
|
remove_small_and_small_holes(ex_polygons, Slic3r::sqr(scale_(0.1f)));
|
||||||
// and consequently with the extraction of colored segments by function extract_colored_segments.
|
// Occasionally, some input polygons contained self-intersections that caused problems with Voronoi diagrams
|
||||||
// Calling simplify_polygons removes these self-intersections.
|
// and consequently with the extraction of colored segments by function extract_colored_segments.
|
||||||
// Also, occasionally input polygons contained several points very close together (distance between points is 1 or so).
|
// Calling simplify_polygons removes these self-intersections.
|
||||||
// Such close points sometimes caused that the Voronoi diagram has self-intersecting edges around these vertices.
|
// Also, occasionally input polygons contained several points very close together (distance between points is 1 or so).
|
||||||
// This consequently leads to issues with the extraction of colored segments by function extract_colored_segments.
|
// Such close points sometimes caused that the Voronoi diagram has self-intersecting edges around these vertices.
|
||||||
// Calling expolygons_simplify fixed these issues.
|
// This consequently leads to issues with the extraction of colored segments by function extract_colored_segments.
|
||||||
input_polygons[layer_idx] = simplify_polygons(to_polygons(expolygons_simplify(offset_ex(ex_polygons, -SCALED_EPSILON), SCALED_EPSILON)));
|
// Calling expolygons_simplify fixed these issues.
|
||||||
}
|
input_polygons[layer_idx] = simplify_polygons(to_polygons(expolygons_simplify(offset_ex(ex_polygons, -SCALED_EPSILON), SCALED_EPSILON)));
|
||||||
|
}
|
||||||
|
}); // end of parallel_for
|
||||||
|
|
||||||
for (size_t layer_idx = 0; layer_idx < layers.size(); ++layer_idx) {
|
for (size_t layer_idx = 0; layer_idx < layers.size(); ++layer_idx) {
|
||||||
BoundingBox bbox(get_extents(input_polygons[layer_idx]));
|
BoundingBox bbox(get_extents(input_polygons[layer_idx]));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue