From 21b38db4884b26f434e6a2da6657d83cde906970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Wed, 9 Jun 2021 17:13:30 +0200 Subject: [PATCH] Added using the move operator in some parts of multi-material segmentation. --- src/libslic3r/MultiMaterialSegmentation.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index 6f1ca61c0..be1b838fd 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -185,7 +185,8 @@ static bool vertex_equal_to_point(const Voronoi::VD::vertex_type &vertex, const ulp_cmp(vertex.y(), double(ipt.y()), ULPS) == ulp_cmp_type::EQUAL; } -static inline bool vertex_equal_to_point(const Voronoi::VD::vertex_type *vertex, const Point &ipt) { +static inline bool vertex_equal_to_point(const Voronoi::VD::vertex_type *vertex, const Point &ipt) +{ return vertex_equal_to_point(*vertex, ipt); } @@ -1137,11 +1138,10 @@ static void cut_segmented_layers(const std::vector std::vector> segmented_regions_cuts; for (const std::pair &colored_expoly : segmented_regions[layer_idx]) { ExPolygons cut_colored_expoly = diff_ex(colored_expoly.first, offset_ex(input_expolygons[layer_idx], cut_width)); - for (const ExPolygon &expoly : cut_colored_expoly) { - segmented_regions_cuts.emplace_back(expoly, colored_expoly.second); - } + for (ExPolygon &expoly : cut_colored_expoly) + segmented_regions_cuts.emplace_back(std::move(expoly), colored_expoly.second); } - segmented_regions[layer_idx] = segmented_regions_cuts; + segmented_regions[layer_idx] = std::move(segmented_regions_cuts); } }); // end of parallel_for BOOST_LOG_TRIVIAL(debug) << "MMU segmentation - cutting segmented layers in parallel - end"; @@ -1519,9 +1519,8 @@ std::vector>> multi_material_segmentati tbb::parallel_for(tbb::blocked_range(0, print_object.layers().size()), [&](const tbb::blocked_range &range) { for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) { throw_on_cancel_callback(); - auto comp = [&edge_grids, layer_idx](const PaintedLine &first, const PaintedLine &second) { - Point first_start_p = *(edge_grids[layer_idx].contours()[first.contour_idx].begin() + first.line_idx); - + auto comp = [&input_polygons, layer_idx](const PaintedLine &first, const PaintedLine &second) { + Point first_start_p = input_polygons[layer_idx][first.contour_idx][first.line_idx]; return first.contour_idx < second.contour_idx || (first.contour_idx == second.contour_idx && (first.line_idx < second.line_idx || @@ -1538,8 +1537,8 @@ std::vector>> multi_material_segmentati remove_multiple_edges_in_vertices(graph, color_poly); graph.remove_nodes_with_one_arc(); std::vector> segmentation = extract_colored_segments(graph); - for (const std::pair ®ion : segmentation) - segmented_regions[layer_idx].emplace_back(region); + for (std::pair ®ion : segmentation) + segmented_regions[layer_idx].emplace_back(std::move(region)); } } }); // end of parallel_for