From dc06fd1e344bec2b278efca895674adcd443dd88 Mon Sep 17 00:00:00 2001 From: ptahmose Date: Sat, 18 Nov 2023 17:31:57 +0100 Subject: [PATCH] cosmetic --- Src/libCZI/utilities.cpp | 46 +++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/Src/libCZI/utilities.cpp b/Src/libCZI/utilities.cpp index 8eb385a4..0128ef23 100644 --- a/Src/libCZI/utilities.cpp +++ b/Src/libCZI/utilities.cpp @@ -438,41 +438,39 @@ void RectangleCoverageCalculator::AddRectangle(const libCZI::IntRect& rectangle) } else { - for (auto i = this->splitters_.begin(); i != this->splitters_.end(); ++i) + for (auto splitter = this->splitters_.begin(); splitter != this->splitters_.end(); ++splitter) { // does the rectangle intersect with one of existing rectangles? - if (i->IntersectsWith(rectangle) == true) + if (splitter->IntersectsWith(rectangle) == true) { // check if it is completely contained in the current existing rectangle - if (RectangleCoverageCalculator::IsCompletelyContained(*i, rectangle) == true) + if (RectangleCoverageCalculator::IsCompletelyContained(*splitter, rectangle) == true) { // ok, in this case we have nothing to do! return; } - else - { - // check if the existing rectangle is completely contained in the new one - if (RectangleCoverageCalculator::IsCompletelyContained(rectangle, *i) == true) - { - // in this case we remove the (smaller) rect splitters[i] (which is fully - // contained in rectangle) from our list and add rectangle - this->splitters_.erase(i); - this->AddRectangle(rectangle); - return; - } - - // ok, the rectangle overlap only partially... then let's cut the new rectangle into pieces - // (which do not intersect with the currently investigated rectangle) and try - // to add those pieces - std::array splitUpRects; - const int number_of_split_up_rects = SplitUpIntoNonOverlapping(*i, rectangle, splitUpRects); - for (int n = 0; n < number_of_split_up_rects; ++n) - { - this->AddRectangle(splitUpRects[n]); - } + // check if the existing rectangle is completely contained in the new one + if (RectangleCoverageCalculator::IsCompletelyContained(rectangle, *splitter) == true) + { + // in this case we remove the (smaller) rect splitters[i] (which is fully + // contained in rectangle) from our list and add rectangle + this->splitters_.erase(splitter); + this->AddRectangle(rectangle); return; } + + // ok, the rectangle overlap only partially... then let's cut the new rectangle into pieces + // (which do not intersect with the currently investigated rectangle) and try + // to add those pieces + std::array splitUpRects; + const int number_of_split_up_rects = SplitUpIntoNonOverlapping(*splitter, rectangle, splitUpRects); + for (int n = 0; n < number_of_split_up_rects; ++n) + { + this->AddRectangle(splitUpRects[n]); + } + + return; } }