From cf44ad22fe65243937861c7062b80e6951206f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0ach?= Date: Tue, 26 Sep 2023 13:10:19 +0200 Subject: [PATCH 1/2] Use size_t instead of int for index. The functions estamate_points_properties used some ints to manipulate indexes that led to compiler warrnings. --- src/libslic3r/GCode/ExtrusionProcessor.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/GCode/ExtrusionProcessor.hpp b/src/libslic3r/GCode/ExtrusionProcessor.hpp index 774413bd53..9f8ec59a7b 100644 --- a/src/libslic3r/GCode/ExtrusionProcessor.hpp +++ b/src/libslic3r/GCode/ExtrusionProcessor.hpp @@ -50,27 +50,27 @@ std::vector estimate_points_properties(const POINTS float max_line_length = -1.0f) { bool looped = input_points.front() == input_points.back(); - std::function get_prev_index = [](int idx, size_t count) { + std::function get_prev_index = [](size_t idx, size_t count) { if (idx > 0) { return idx - 1; } else return idx; }; if (looped) { - get_prev_index = [](int idx, size_t count) { + get_prev_index = [](size_t idx, size_t count) { if (idx == 0) idx = count; return --idx; }; }; - std::function get_next_index = [](int idx, size_t size) { + std::function get_next_index = [](size_t idx, size_t size) { if (idx + 1 < size) { return idx + 1; } else return idx; }; if (looped) { - get_next_index = [](int idx, size_t count) { + get_next_index = [](size_t idx, size_t count) { if (++idx == count) idx = 0; return idx; @@ -186,7 +186,7 @@ std::vector estimate_points_properties(const POINTS float accumulated_distance = 0; std::vector distances_for_curvature(points.size()); - for (int point_idx = 0; point_idx < int(points.size()); ++point_idx) { + for (size_t point_idx = 0; point_idx < points.size(); ++point_idx) { const ExtendedPoint &a = points[point_idx]; const ExtendedPoint &b = points[get_prev_index(point_idx, points.size())]; From 11273b29aca32309cc9988917c46375cf081963e Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 26 Sep 2023 13:04:32 +0200 Subject: [PATCH 2/2] Fixed compiler warnings --- src/libslic3r/Arrange/Core/NFP/EdgeCache.cpp | 2 +- src/libslic3r/Arrange/Core/NFP/NFP.cpp | 2 +- src/libslic3r/Color.cpp | 2 +- src/libslic3r/Support/TreeSupport.cpp | 2 +- src/slic3r/GUI/TextLines.cpp | 2 +- tests/libslic3r/test_support_spots_generator.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/Arrange/Core/NFP/EdgeCache.cpp b/src/libslic3r/Arrange/Core/NFP/EdgeCache.cpp index 0e820f02c8..7ed3ec451f 100644 --- a/src/libslic3r/Arrange/Core/NFP/EdgeCache.cpp +++ b/src/libslic3r/Arrange/Core/NFP/EdgeCache.cpp @@ -94,7 +94,7 @@ void fill_distances(const Polygon &poly, std::vector &distances) double dist = 0.; auto lrange = line_range(poly); - for (const Line &l : lrange) { + for (const Line l : lrange) { dist += l.length(); distances.emplace_back(dist); } diff --git a/src/libslic3r/Arrange/Core/NFP/NFP.cpp b/src/libslic3r/Arrange/Core/NFP/NFP.cpp index f1ad25d842..c38516875a 100644 --- a/src/libslic3r/Arrange/Core/NFP/NFP.cpp +++ b/src/libslic3r/Arrange/Core/NFP/NFP.cpp @@ -132,7 +132,7 @@ Polygon ifp_convex_convex(const Polygon &fixed, const Polygon &movable) // the zero area polygon formed by the edge. The union of all these sub-nfps // will contain a hole that is the actual ifp. auto lrange = line_range(fixed); - for (const Line &l : lrange) { // Older mac compilers generate warnging if line_range is called in-place + for (const Line l : lrange) { // Older mac compilers generate warnging if line_range is called in-place Polygon fixed = {l.a, l.b}; subnfps.emplace_back(nfp_convex_convex_legacy(fixed, movable)); } diff --git a/src/libslic3r/Color.cpp b/src/libslic3r/Color.cpp index aecdd0b794..356b2be652 100644 --- a/src/libslic3r/Color.cpp +++ b/src/libslic3r/Color.cpp @@ -29,7 +29,7 @@ static void RGBtoHSV(float r, float g, float b, float& h, float& s, float& v) h = 60.0f * (std::fmod(((g - b) / delta), 6.0f)); else if (max_comp == g) h = 60.0f * (((b - r) / delta) + 2.0f); - else if (max_comp == b) + else // max_comp == b h = 60.0f * (((r - g) / delta) + 4.0f); s = (max_comp > 0.0f) ? delta / max_comp : 0.0f; diff --git a/src/libslic3r/Support/TreeSupport.cpp b/src/libslic3r/Support/TreeSupport.cpp index b12cc8a2fa..d82cb58142 100644 --- a/src/libslic3r/Support/TreeSupport.cpp +++ b/src/libslic3r/Support/TreeSupport.cpp @@ -81,7 +81,7 @@ static inline void validate_range(const MultiPoint &mp) validate_range(mp.points); } -static inline void validate_range(const Polygons &polygons) +[[maybe_unused]] static inline void validate_range(const Polygons &polygons) { for (const Polygon &p : polygons) validate_range(p); diff --git a/src/slic3r/GUI/TextLines.cpp b/src/slic3r/GUI/TextLines.cpp index bc3eb58a91..ca24746be8 100644 --- a/src/slic3r/GUI/TextLines.cpp +++ b/src/slic3r/GUI/TextLines.cpp @@ -154,7 +154,7 @@ TextLines select_closest_contour(const std::vector &line_contours) { std::vector linesf = to_linesf(expolygons); AABBTreeIndirect::Tree2d tree = AABBTreeLines::build_aabb_tree_over_indexed_lines(linesf); - size_t line_idx; + size_t line_idx = 0; Vec2d hit_point; // double distance = AABBTreeLines::squared_distance_to_indexed_lines(linesf, tree, zero, line_idx, hit_point); diff --git a/tests/libslic3r/test_support_spots_generator.cpp b/tests/libslic3r/test_support_spots_generator.cpp index 3ea8dcd070..71ae1ed6d0 100644 --- a/tests/libslic3r/test_support_spots_generator.cpp +++ b/tests/libslic3r/test_support_spots_generator.cpp @@ -72,7 +72,7 @@ TEST_CASE("Moments calculation for rotated axis.", "[SupportSpotsGenerator]") { Integrals integrals{{polygon}}; std::mt19937 generator{std::random_device{}()}; - std::uniform_real_distribution angle_distribution{0, 2*M_PI}; + std::uniform_real_distribution angle_distribution{0.f, float(2*M_PI)}; // Meassured counterclockwise from (1, 0) const float angle = angle_distribution(generator);