Fix arrange tests on raspberry pi

There were indeed floating point divisions with zero
This commit is contained in:
tamasmeszaros 2023-08-29 17:34:06 +02:00
parent 9da03dfc9f
commit 3fe051b0ad
2 changed files with 9 additions and 1 deletions

View File

@ -30,6 +30,9 @@ void EdgeCache::sample_contour(double accuracy, std::vector<ContourLocation> &sa
const auto N = m_contour.distances.size();
const auto S = stride(N, accuracy);
if (N == 0 || S == 0)
return;
samples.reserve(N / S + 1);
for(size_t i = 0; i < N; i += S) {
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 SH = stride(NH, accuracy);
if (NH == 0 || SH == 0)
continue;
samples.reserve(samples.size() + NH / SH + 1);
for (size_t i = 0; i < NH; i += SH) {
samples.emplace_back(

View File

@ -48,8 +48,9 @@ public:
// when fetching corners.
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>(
std::round(N / std::pow(N, std::pow(accuracy, 1./3.)))
std::round(N / std::pow(n, std::pow(accuracy, 1./3.)))
);
}