diff --git a/include/plsm/Subpaving.inl b/include/plsm/Subpaving.inl index ed2cd45..614c720 100644 --- a/include/plsm/Subpaving.inl +++ b/include/plsm/Subpaving.inl @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -103,9 +104,13 @@ Subpaving::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::filled(1); for (auto i : makeIntervalRange(Dim)) { if (ratioProduct[i] < extents[i]) {