Skip to content

Commit

Permalink
Limit ratio loop to enable error to be thrown (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipFackler committed Jun 28, 2023
1 parent 7820fc6 commit 934c569
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions include/plsm/Subpaving.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <algorithm>
#include <array>
#include <cmath>
#include <fstream>
#include <numeric>
#include <stdexcept>
Expand Down Expand Up @@ -103,9 +104,13 @@ Subpaving<TScalar, Dim, TEnum, TItemData, TMemSpace>::processSubdivisionRatios(
return ret;
};

// Limit loop to a reasonable iteration count
auto maxIter = std::log2(*std::max_element(begin(extents), end(extents)));

// Create additional ratio(s) until space is fully subdivided
for (;;) {
bool needAnotherLevel = false;
bool needAnotherLevel = false;
for (int n = 0; n < maxIter; ++n) {
needAnotherLevel = false;
auto nextRatio = SubdivisionRatio<Dim>::filled(1);
for (auto i : makeIntervalRange(Dim)) {
if (ratioProduct[i] < extents[i]) {
Expand Down

0 comments on commit 934c569

Please sign in to comment.