From f54ba6aeafaf585374426af9d56b029d4b0ea251 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 24 Aug 2022 14:39:13 +0200 Subject: [PATCH] WIP TreeSupports: Fixed some more compiler warnings --- src/libslic3r/SupportMaterial.cpp | 8 ++++---- src/libslic3r/TreeModelVolumes.cpp | 18 +++++++++--------- src/libslic3r/TreeSupport.cpp | 15 +++++++-------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index 7082b9f1f..e26be7644 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -110,7 +110,7 @@ void export_support_surface_type_legend_to_svg(SVG &svg, const Point &pos) svg.draw_legend(Point(pos_x, pos_y), "intermediate" , support_surface_type_to_color_name(SupporLayerType::Intermediate)); } -void export_print_z_polygons_to_svg(const char *path, SupportGeneratorLayer ** const layers, size_t n_layers) +void export_print_z_polygons_to_svg(const char *path, SupportGeneratorLayer ** const layers, int n_layers) { BoundingBox bbox; for (int i = 0; i < n_layers; ++ i) @@ -129,10 +129,10 @@ void export_print_z_polygons_to_svg(const char *path, SupportGeneratorLayer ** c } void export_print_z_polygons_and_extrusions_to_svg( - const char *path, + const char *path, SupportGeneratorLayer ** const layers, - size_t n_layers, - SupportLayer &support_layer) + int n_layers, + SupportLayer &support_layer) { BoundingBox bbox; for (int i = 0; i < n_layers; ++ i) diff --git a/src/libslic3r/TreeModelVolumes.cpp b/src/libslic3r/TreeModelVolumes.cpp index 59986ff30..813696225 100644 --- a/src/libslic3r/TreeModelVolumes.cpp +++ b/src/libslic3r/TreeModelVolumes.cpp @@ -465,10 +465,10 @@ void TreeModelVolumes::calculateCollision(const coord_t radius, const LayerIndex Polygons collisions; for (int i = -z_distance_bottom_layers; i <= z_distance_top_layers; ++ i) { int j = layer_idx + i - min_layer_bottom; - if (j >= 0 && j < collision_areas_offsetted.size()) + if (j >= 0 && j < int(collision_areas_offsetted.size())) append(collisions, collision_areas_offsetted[j]); } - collisions = last && layer_idx < anti_overhang.size() ? union_(collisions, offset(union_ex(anti_overhang[layer_idx]), radius, ClipperLib::jtMiter, 1.2)) : union_(collisions); + collisions = last && layer_idx < int(anti_overhang.size()) ? union_(collisions, offset(union_ex(anti_overhang[layer_idx]), radius, ClipperLib::jtMiter, 1.2)) : union_(collisions); auto &dst = data[layer_idx - (min_layer_last + 1)]; if (last) { if (! dst.empty()) @@ -490,7 +490,7 @@ void TreeModelVolumes::calculateCollision(const coord_t radius, const LayerIndex assert(layer_idx_below >= 0); auto ¤t = collision_areas_offsetted[layer_idx - min_layer_bottom]; auto &below = collision_areas_offsetted[layer_idx_below]; - auto placable = diff(below, layer_idx < anti_overhang.size() ? union_(current, anti_overhang[layer_idx - (z_distance_bottom_layers + 1)]) : current); + auto placable = diff(below, layer_idx < int(anti_overhang.size()) ? union_(current, anti_overhang[layer_idx - (z_distance_bottom_layers + 1)]) : current); auto &dst = data_placeable[layer_idx - (min_layer_last + 1)]; if (last) { if (! dst.empty()) @@ -524,10 +524,10 @@ void TreeModelVolumes::calculateCollisionHolefree(const std::vector(0, max_layer + 1, keys.size()), - [&](const tbb::blocked_range &range) { + tbb::parallel_for(tbb::blocked_range(0, max_layer + 1, keys.size()), + [&](const tbb::blocked_range &range) { RadiusLayerPolygonCacheData data; - for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) { + for (LayerIndex layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) { for (RadiusLayerPair key : keys) if (layer_idx <= key.second) { // Logically increase the collision by m_increase_until_radius @@ -565,7 +565,7 @@ void TreeModelVolumes::calculateAvoidance(const std::vector &ke std::vector avoidance_tasks; avoidance_tasks.reserve((int(to_build_plate) + int(to_model)) * keys.size() * size_t(AvoidanceType::Count)); - for (int iter_idx = 0; iter_idx < 2 * keys.size() * size_t(AvoidanceType::Count); ++ iter_idx) { + for (int iter_idx = 0; iter_idx < 2 * int(keys.size()) * int(AvoidanceType::Count); ++ iter_idx) { AvoidanceTask task{ AvoidanceType(iter_idx % int(AvoidanceType::Count)), keys[iter_idx / 6].first, // radius @@ -666,7 +666,7 @@ void TreeModelVolumes::calculatePlaceables(const coord_t radius, const LayerInde tbb::parallel_for(tbb::blocked_range(std::max(1, start_layer), max_required_layer + 1), [this, &data, radius, start_layer](const tbb::blocked_range& range) { - for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) + for (LayerIndex layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) data[layer_idx - start_layer] = offset(union_ex(getPlaceableAreas(0, layer_idx)), - radius, jtMiter, 1.2); }); #ifdef SLIC3R_TREESUPPORTS_PROGRESS @@ -730,7 +730,7 @@ void TreeModelVolumes::calculateWallRestrictions(const std::vector(min_layer_bottom, max_required_layer + 1), [this, &data, &data_min, radius, min_layer_bottom](const tbb::blocked_range &range) { - for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) { + for (LayerIndex layer_idx = range.begin(); layer_idx < range.end(); ++ layer_idx) { data[layer_idx - min_layer_bottom] = polygons_simplify( // radius contains m_current_min_xy_dist_delta already if required intersection(getCollision(0, layer_idx, false), getCollision(radius, layer_idx - 1, true)), diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index bddd6f2c4..0d5e520a8 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -186,9 +186,9 @@ static std::vector> polyline_sample_next_point_at_dis } coord_t step_size = safe_step_size; - size_t steps = distance > last_step_offset_without_check ? (distance - last_step_offset_without_check) / step_size : 0; + int steps = distance > last_step_offset_without_check ? (distance - last_step_offset_without_check) / step_size : 0; if (distance - steps * step_size > last_step_offset_without_check) { if ((steps + 1) * step_size <= distance) // This will be the case when last_step_offset_without_check >= safe_step_size @@ -1015,7 +1015,7 @@ static std::optional> polyline_sample_next_point_at_dis steps = distance / step_size; } // offset in steps - for (size_t i = 0; i < steps; i++) { + for (int i = 0; i < steps; ++ i) { ret = diff(offset(ret, step_size, ClipperLib::jtRound, scaled(0.01)), collision_trimmed()); // ensure that if many offsets are done the performance does not suffer extremely by the new vertices of jtRound. if (i % 10 == 7) @@ -2309,7 +2309,7 @@ bool TreeSupport::setToModelContact(std::vector>& move moveInside(*checked[last_successfull_layer - layer_idx]->area, best); checked[last_successfull_layer - layer_idx]->result_on_layer = best; - BOOST_LOG_TRIVIAL(debug) << "Added gracious Support On Model Point (" << best.x() << "," << best.y() << "). The current layer is ", last_successfull_layer; + BOOST_LOG_TRIVIAL(debug) << "Added gracious Support On Model Point (" << best.x() << "," << best.y() << "). The current layer is " << last_successfull_layer; return last_successfull_layer != layer_idx; } @@ -2320,12 +2320,11 @@ bool TreeSupport::setToModelContact(std::vector>& move moveInside(*first_elem->area, best); first_elem->result_on_layer = best; first_elem->to_model_gracious = false; - BOOST_LOG_TRIVIAL(debug) << "Added NON gracious Support On Model Point (" << best.x() << "," << best.y() << "). The current layer is ", layer_idx; + BOOST_LOG_TRIVIAL(debug) << "Added NON gracious Support On Model Point (" << best.x() << "," << best.y() << "). The current layer is " << layer_idx; return false; } } - void TreeSupport::createNodesFromArea(std::vector>& move_bounds) { // Initialize points on layer 0, with a "random" point in the influence area. Point is chosen based on an inaccurate estimate where the branches will split into two, but every point inside the influence area would produce a valid result.