From 03c59056086f79570869da1668d4dbe343e12f8e Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Thu, 20 Feb 2025 22:07:30 +0800 Subject: [PATCH] FIX: Int32 out-of-bounds problem jira: none Change-Id: I1dfc611b214e6e4c6641b8de90920e5a5881373f --- src/libslic3r/libslic3r.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index aba7f9d52..4dbe46d3c 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -50,12 +50,12 @@ using coordf_t = double; // for a trheshold in a difference of radians, // for a threshold of a cross product of two non-normalized vectors etc. static constexpr double EPSILON = 1e-4; -// Scaling factor for a conversion from coord_t to coordf_t: 10e-6 +// Scaling factor for a conversion from coord_t to coordf_t: 1e-5 // This scaling generates a following fixed point representation with for a 32bit integer: // 0..4294mm with 1nm resolution // int32_t fits an interval of (-2147.48mm, +2147.48mm) // with int64_t we don't have to worry anymore about the size of the int. -static constexpr double SCALING_FACTOR = 0.000001; +static constexpr double SCALING_FACTOR = 0.00001; static constexpr double PI = 3.141592653589793238; #define POLY_SIDE_COUNT 24 // for brim ear circle // When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam. @@ -67,7 +67,7 @@ static constexpr double SPARSE_INFILL_RESOLUTION = 0.04; static constexpr double SUPPORT_RESOLUTION = 0.0375; #define SCALED_SUPPORT_RESOLUTION (SUPPORT_RESOLUTION / SCALING_FACTOR) -// Maximum perimeter length for the loop to apply the small perimeter speed. +// Maximum perimeter length for the loop to apply the small perimeter speed. #define SMALL_PERIMETER_LENGTH(LENGTH) (((LENGTH)/SCALING_FACTOR)*2*PI) static constexpr double INSET_OVERLAP_TOLERANCE = 0.4; // 3mm ring around the top / bottom / bridging areas. @@ -110,7 +110,7 @@ using deque = template inline T unscale(Q v) { return T(v) * T(SCALING_FACTOR); } -enum Axis { +enum Axis { X=0, Y, Z, @@ -183,7 +183,7 @@ inline void append_reversed(std::vector& dest, std::vector&& src) // Casting an std::vector<> from one type to another type without warnings about a loss of accuracy. template -std::vector cast(const std::vector &src) +std::vector cast(const std::vector &src) { std::vector dst; dst.reserve(src.size()); @@ -221,7 +221,7 @@ ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKey ForwardIt it; typename std::iterator_traits::difference_type count, step; count = std::distance(first, last); - + while (count > 0) { it = first; step = count / 2; @@ -240,10 +240,10 @@ ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKey template> ForwardIt binary_find(ForwardIt first, ForwardIt last, const T& value, Compare comp={}) { - // Note: BOTH type T and the type after ForwardIt is dereferenced - // must be implicitly convertible to BOTH Type1 and Type2, used in Compare. + // Note: BOTH type T and the type after ForwardIt is dereferenced + // must be implicitly convertible to BOTH Type1 and Type2, used in Compare. // This is stricter than lower_bound requirement (see above) - + first = std::lower_bound(first, last, value, comp); return first != last && !comp(value, *first) ? first : last; } @@ -252,10 +252,10 @@ ForwardIt binary_find(ForwardIt first, ForwardIt last, const T& value, Compare c template ForwardIt binary_find_by_predicate(ForwardIt first, ForwardIt last, LowerThanKeyPredicate lower_thank_key, EqualToKeyPredicate equal_to_key) { - // Note: BOTH type T and the type after ForwardIt is dereferenced - // must be implicitly convertible to BOTH Type1 and Type2, used in Compare. + // Note: BOTH type T and the type after ForwardIt is dereferenced + // must be implicitly convertible to BOTH Type1 and Type2, used in Compare. // This is stricter than lower_bound requirement (see above) - + first = lower_bound_by_predicate(first, last, lower_thank_key); return first != last && equal_to_key(*first) ? first : last; } @@ -316,7 +316,7 @@ template struct is_scaled_coord // return type will be bool. // For more info how to use, see docs for std::enable_if // -template +template using FloatingOnly = std::enable_if_t::value, O>; template