./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
22 / 22
100.0%
Branches:
8 / 8
100.0%
Functions:
2 / 2
100.0%

src/raster/mapped_bounds.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief `MappedBounds`, the box around a box's corners mapped by a transform.
5 #pragma once
6
7 #include "terraingen/geometry/geometry.h"
8
9 #include <cmath>
10 #include <initializer_list>
11 #include <limits>
12
13 namespace terraingen {
14
15 /// The axis-aligned box around the four corners of `box` mapped by `map`.
16 /// @tparam Map Callable as `Vec2d(double x, double y)`.
17 46696 template <typename Map> Bounds2d MappedBounds(const Bounds2d& box, const Map& map) {
18 46696 constexpr double kInf = std::numeric_limits<double>::infinity();
19 46696 Bounds2d bounds{kInf, kInf, -kInf, -kInf};
20
4/4
terraingen::Bounds2d terraingen::MappedBounds<terraingen::PixelWindowIn(terraingen::RasterGrid const&, terraingen::Bounds2d const&)::{lambda(double, double)#1}>(terraingen::Bounds2d const&, terraingen::PixelWindowIn(terraingen::RasterGrid const&, terraingen::Bounds2d const&)::{lambda(double, double)#1} const&):
✓ Branch 0 taken 89746 times.
✓ Branch 1 taken 44873 times.
terraingen::Bounds2d terraingen::MappedBounds<terraingen::RasterGrid::Bounds() const::{lambda(double, double)#1}>(terraingen::Bounds2d const&, terraingen::RasterGrid::Bounds() const::{lambda(double, double)#1} const&):
✓ Branch 0 taken 3646 times.
✓ Branch 1 taken 1823 times.
140088 for (const double x : {box.minX, box.maxX}) {
21
4/4
terraingen::Bounds2d terraingen::MappedBounds<terraingen::PixelWindowIn(terraingen::RasterGrid const&, terraingen::Bounds2d const&)::{lambda(double, double)#1}>(terraingen::Bounds2d const&, terraingen::PixelWindowIn(terraingen::RasterGrid const&, terraingen::Bounds2d const&)::{lambda(double, double)#1} const&):
✓ Branch 1 taken 179492 times.
✓ Branch 2 taken 89746 times.
terraingen::Bounds2d terraingen::MappedBounds<terraingen::RasterGrid::Bounds() const::{lambda(double, double)#1}>(terraingen::Bounds2d const&, terraingen::RasterGrid::Bounds() const::{lambda(double, double)#1} const&):
✓ Branch 0 taken 7292 times.
✓ Branch 1 taken 3646 times.
280176 for (const double y : {box.minY, box.maxY}) {
22 186784 const Vec2d corner = map(x, y);
23 186784 bounds.minX = std::fmin(bounds.minX, corner.x);
24 186784 bounds.minY = std::fmin(bounds.minY, corner.y);
25 186784 bounds.maxX = std::fmax(bounds.maxX, corner.x);
26 186784 bounds.maxY = std::fmax(bounds.maxY, corner.y);
27 }
28 }
29 46696 return bounds;
30 }
31
32 } // namespace terraingen
33