mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-17 02:05:55 +08:00
Fix arrange tests on raspberry pi
There were indeed floating point divisions with zero
This commit is contained in:
parent
9da03dfc9f
commit
3fe051b0ad
@ -30,6 +30,9 @@ void EdgeCache::sample_contour(double accuracy, std::vector<ContourLocation> &sa
|
|||||||
const auto N = m_contour.distances.size();
|
const auto N = m_contour.distances.size();
|
||||||
const auto S = stride(N, accuracy);
|
const auto S = stride(N, accuracy);
|
||||||
|
|
||||||
|
if (N == 0 || S == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
samples.reserve(N / S + 1);
|
samples.reserve(N / S + 1);
|
||||||
for(size_t i = 0; i < N; i += S) {
|
for(size_t i = 0; i < N; i += S) {
|
||||||
samples.emplace_back(
|
samples.emplace_back(
|
||||||
@ -41,6 +44,10 @@ void EdgeCache::sample_contour(double accuracy, std::vector<ContourLocation> &sa
|
|||||||
|
|
||||||
const auto NH = hc.distances.size();
|
const auto NH = hc.distances.size();
|
||||||
const auto SH = stride(NH, accuracy);
|
const auto SH = stride(NH, accuracy);
|
||||||
|
|
||||||
|
if (NH == 0 || SH == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
samples.reserve(samples.size() + NH / SH + 1);
|
samples.reserve(samples.size() + NH / SH + 1);
|
||||||
for (size_t i = 0; i < NH; i += SH) {
|
for (size_t i = 0; i < NH; i += SH) {
|
||||||
samples.emplace_back(
|
samples.emplace_back(
|
||||||
|
@ -48,8 +48,9 @@ public:
|
|||||||
// when fetching corners.
|
// when fetching corners.
|
||||||
static inline size_t stride(const size_t N, double accuracy)
|
static inline size_t stride(const size_t N, double accuracy)
|
||||||
{
|
{
|
||||||
|
size_t n = std::max(size_t{1}, N);
|
||||||
return static_cast<coord_t>(
|
return static_cast<coord_t>(
|
||||||
std::round(N / std::pow(N, std::pow(accuracy, 1./3.)))
|
std::round(N / std::pow(n, std::pow(accuracy, 1./3.)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user