FIX: Int32 out-of-bounds problem
jira: none Change-Id: I1dfc611b214e6e4c6641b8de90920e5a5881373f
This commit is contained in:
parent
d7bc191cd3
commit
03c5905608
|
@ -50,12 +50,12 @@ using coordf_t = double;
|
||||||
// for a trheshold in a difference of radians,
|
// for a trheshold in a difference of radians,
|
||||||
// for a threshold of a cross product of two non-normalized vectors etc.
|
// for a threshold of a cross product of two non-normalized vectors etc.
|
||||||
static constexpr double EPSILON = 1e-4;
|
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:
|
// This scaling generates a following fixed point representation with for a 32bit integer:
|
||||||
// 0..4294mm with 1nm resolution
|
// 0..4294mm with 1nm resolution
|
||||||
// int32_t fits an interval of (-2147.48mm, +2147.48mm)
|
// 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.
|
// 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;
|
static constexpr double PI = 3.141592653589793238;
|
||||||
#define POLY_SIDE_COUNT 24 // for brim ear circle
|
#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.
|
// 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;
|
static constexpr double SUPPORT_RESOLUTION = 0.0375;
|
||||||
#define SCALED_SUPPORT_RESOLUTION (SUPPORT_RESOLUTION / SCALING_FACTOR)
|
#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)
|
#define SMALL_PERIMETER_LENGTH(LENGTH) (((LENGTH)/SCALING_FACTOR)*2*PI)
|
||||||
static constexpr double INSET_OVERLAP_TOLERANCE = 0.4;
|
static constexpr double INSET_OVERLAP_TOLERANCE = 0.4;
|
||||||
// 3mm ring around the top / bottom / bridging areas.
|
// 3mm ring around the top / bottom / bridging areas.
|
||||||
|
@ -110,7 +110,7 @@ using deque =
|
||||||
template<typename T, typename Q>
|
template<typename T, typename Q>
|
||||||
inline T unscale(Q v) { return T(v) * T(SCALING_FACTOR); }
|
inline T unscale(Q v) { return T(v) * T(SCALING_FACTOR); }
|
||||||
|
|
||||||
enum Axis {
|
enum Axis {
|
||||||
X=0,
|
X=0,
|
||||||
Y,
|
Y,
|
||||||
Z,
|
Z,
|
||||||
|
@ -183,7 +183,7 @@ inline void append_reversed(std::vector<T>& dest, std::vector<T>&& src)
|
||||||
|
|
||||||
// Casting an std::vector<> from one type to another type without warnings about a loss of accuracy.
|
// Casting an std::vector<> from one type to another type without warnings about a loss of accuracy.
|
||||||
template<typename T_TO, typename T_FROM>
|
template<typename T_TO, typename T_FROM>
|
||||||
std::vector<T_TO> cast(const std::vector<T_FROM> &src)
|
std::vector<T_TO> cast(const std::vector<T_FROM> &src)
|
||||||
{
|
{
|
||||||
std::vector<T_TO> dst;
|
std::vector<T_TO> dst;
|
||||||
dst.reserve(src.size());
|
dst.reserve(src.size());
|
||||||
|
@ -221,7 +221,7 @@ ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKey
|
||||||
ForwardIt it;
|
ForwardIt it;
|
||||||
typename std::iterator_traits<ForwardIt>::difference_type count, step;
|
typename std::iterator_traits<ForwardIt>::difference_type count, step;
|
||||||
count = std::distance(first, last);
|
count = std::distance(first, last);
|
||||||
|
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
it = first;
|
it = first;
|
||||||
step = count / 2;
|
step = count / 2;
|
||||||
|
@ -240,10 +240,10 @@ ForwardIt lower_bound_by_predicate(ForwardIt first, ForwardIt last, LowerThanKey
|
||||||
template<class ForwardIt, class T, class Compare=std::less<>>
|
template<class ForwardIt, class T, class Compare=std::less<>>
|
||||||
ForwardIt binary_find(ForwardIt first, ForwardIt last, const T& value, Compare comp={})
|
ForwardIt binary_find(ForwardIt first, ForwardIt last, const T& value, Compare comp={})
|
||||||
{
|
{
|
||||||
// Note: BOTH type T and the type after ForwardIt is dereferenced
|
// Note: BOTH type T and the type after ForwardIt is dereferenced
|
||||||
// must be implicitly convertible to BOTH Type1 and Type2, used in Compare.
|
// must be implicitly convertible to BOTH Type1 and Type2, used in Compare.
|
||||||
// This is stricter than lower_bound requirement (see above)
|
// This is stricter than lower_bound requirement (see above)
|
||||||
|
|
||||||
first = std::lower_bound(first, last, value, comp);
|
first = std::lower_bound(first, last, value, comp);
|
||||||
return first != last && !comp(value, *first) ? first : last;
|
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<class ForwardIt, class LowerThanKeyPredicate, class EqualToKeyPredicate>
|
template<class ForwardIt, class LowerThanKeyPredicate, class EqualToKeyPredicate>
|
||||||
ForwardIt binary_find_by_predicate(ForwardIt first, ForwardIt last, LowerThanKeyPredicate lower_thank_key, EqualToKeyPredicate equal_to_key)
|
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
|
// Note: BOTH type T and the type after ForwardIt is dereferenced
|
||||||
// must be implicitly convertible to BOTH Type1 and Type2, used in Compare.
|
// must be implicitly convertible to BOTH Type1 and Type2, used in Compare.
|
||||||
// This is stricter than lower_bound requirement (see above)
|
// This is stricter than lower_bound requirement (see above)
|
||||||
|
|
||||||
first = lower_bound_by_predicate(first, last, lower_thank_key);
|
first = lower_bound_by_predicate(first, last, lower_thank_key);
|
||||||
return first != last && equal_to_key(*first) ? first : last;
|
return first != last && equal_to_key(*first) ? first : last;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ template<class I> struct is_scaled_coord
|
||||||
// return type will be bool.
|
// return type will be bool.
|
||||||
// For more info how to use, see docs for std::enable_if
|
// For more info how to use, see docs for std::enable_if
|
||||||
//
|
//
|
||||||
template<class T, class O = T>
|
template<class T, class O = T>
|
||||||
using FloatingOnly = std::enable_if_t<std::is_floating_point<T>::value, O>;
|
using FloatingOnly = std::enable_if_t<std::is_floating_point<T>::value, O>;
|
||||||
|
|
||||||
template<class T, class O = T>
|
template<class T, class O = T>
|
||||||
|
|
Loading…
Reference in New Issue