From 51cfec55cfd37fd4a3537431d664fea7e1138bfb Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 24 Aug 2022 15:32:23 +0200 Subject: [PATCH] WIP TreeSupports: Fixed yet some more compiler warnings --- src/libslic3r/TreeModelVolumes.cpp | 2 +- src/libslic3r/TreeSupport.cpp | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/TreeModelVolumes.cpp b/src/libslic3r/TreeModelVolumes.cpp index 813696225..956befd99 100644 --- a/src/libslic3r/TreeModelVolumes.cpp +++ b/src/libslic3r/TreeModelVolumes.cpp @@ -615,7 +615,7 @@ void TreeModelVolumes::calculateAvoidance(const std::vector &ke // Merge current layer collisions with shrunk last_avoidance. const Polygons ¤t_layer_collisions = collision_holefree ? getCollisionHolefree(task.radius, layer_idx) : getCollision(task.radius, layer_idx, true); // For mildly steep branch angles only one step will be taken. - for (size_t istep = 0; istep < move_steps; ++ istep) + for (int istep = 0; istep < move_steps; ++ istep) latest_avoidance = union_(current_layer_collisions, offset(latest_avoidance, istep + 1 == move_steps ? - last_move_step : - move_step, diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index 0d5e520a8..de94b792d 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -292,9 +292,10 @@ static bool layer_has_overhangs(const Layer &layer) // +1 makes the threshold inclusive double tan_threshold = support_threshold_auto ? 0. : tan(M_PI * double(support_threshold + 1) / 180.); - tbb::parallel_for(tbb::blocked_range(1, out.size()), - [&print_object, &enforcers_layers, &blockers_layers, support_auto, support_enforce_layers, support_threshold_auto, tan_threshold, &out](const tbb::blocked_range &range) { - for (size_t layer_id = range.begin(); layer_id < range.end(); ++ layer_id) + tbb::parallel_for(tbb::blocked_range(1, out.size()), + [&print_object, &enforcers_layers, &blockers_layers, support_auto, support_enforce_layers, support_threshold_auto, tan_threshold, &out] + (const tbb::blocked_range &range) { + for (LayerIndex layer_id = range.begin(); layer_id < range.end(); ++ layer_id) if (layer_has_overhangs(*print_object.get_layer(layer_id))) { const Polygons raw_overhangs = layer_overhangs(*print_object.get_layer(layer_id)); Polygons overhangs; @@ -319,14 +320,10 @@ static bool layer_has_overhangs(const Layer &layer) diff(clipped_overhangs, lower_layer.lslices) : diff(clipped_overhangs, offset(lower_layer.lslices, lower_layer_offset)); } - if (! enforcers_layers.empty() && ! enforcers_layers[layer_id].empty()) { + if (! enforcers_layers.empty() && ! enforcers_layers[layer_id].empty()) // Has some support enforcers at this layer, apply them to the overhangs, don't apply the support threshold angle. if (Polygons enforced_overhangs = intersection(raw_overhangs, enforcers_layers[layer_id]); ! enforced_overhangs.empty()) - if (overhangs.empty()) - overhangs = std::move(enforced_overhangs); - else - overhangs = union_(overhangs, enforced_overhangs); - } + overhangs = overhangs.empty() ? std::move(enforced_overhangs) : union_(overhangs, enforced_overhangs); out[layer_id] = std::move(overhangs); } }); @@ -2803,11 +2800,11 @@ void TreeSupport::drawAreas( auto &this_layers = support_layer_storage[layer_idx]; size_t cnt_roofs = 0; size_t cnt_layers = 0; - for (const std::pair &data_pair : this_layer_tree_polygons) + for (const std::pair &data_pair : this_layer_tree_polygons) ++ (data_pair.first->missing_roof_layers > data_pair.first->distance_to_top ? cnt_roofs : cnt_layers); this_roofs.reserve(this_roofs.size() + cnt_roofs); this_layers.reserve(this_layers.size() + cnt_layers); - for (const std::pair &data_pair : this_layer_tree_polygons) { + for (const std::pair &data_pair : this_layer_tree_polygons) { auto &src = const_cast(data_pair.second); std::move(std::begin(src), std::end(src), std::back_inserter(data_pair.first->missing_roof_layers > data_pair.first->distance_to_top ? this_roofs : this_layers)); }