TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
6 / 6
100.0%
Branches:
3 / 6
50.0%
Functions:
2 / 2, 1 excl
100.0%

layers/craters/shaping/prepared.h
Line Branch Exec Source
1 /// @file
2 /// @brief `PreparedCrater`, a crater with everything needed to shape it at one sample spacing.
3 #pragma once
4
5 #include "terraingen/layers/craters/degradation/degradation_model.h"
6 #include "terraingen/layers/craters/generation/population.h"
7 #include "terraingen/layers/craters/shaping/apply_options.h"
8 #include "terraingen/layers/craters/shaping/irregularity.h"
9
10 #include <functional>
11 #include <optional>
12 #include <vector>
13
14 namespace terraingen {
15
16 /// A crater's datum: the plane h = `a` + `b` dx + `c` dy, dx and dy in metres east and
17 /// north of its centre.
18 struct Plane {
19 1 double a = 0.0; ///< Height at the centre (m).
20 1 double b = 0.0; ///< Slope eastward (m/m).
21 1 double c = 0.0; ///< Slope northward (m/m).
22
23 /// The height a + b dx + c dy at `dx` east and `dy` north of the centre (m).
24 236219 double At(double dx, double dy) const {
25 236219 return a + b * dx + c * dy;
26 }
27
28
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
1 bool operator==(const Plane&) const = default;
29 };
30
31 /// A crater ready to shape at one sample spacing.
32 struct PreparedCrater {
33 Crater crater; ///< The crater.
34 double resolution = 1.0; ///< `ResolutionWeight` at the sample spacing.
35 CraterState state; ///< Its degradation state.
36 CraterOutline outline{}; ///< Its outline.
37 std::optional<Plane> datum{}; ///< From `FitCraterDatum`; none without a datum.
38 /// Its asymmetry on the ground beneath (`ShapeOnSlopes`); level without a slope response.
39 CraterSlopeShape slope{};
40 };
41
42 /// The craters with a non-zero resolution weight at `spacing`, prepared in `CraterApplyOrder`
43 /// without datums; `reshape`, when set, changes each outline after `OutlineOf`.
44 /// @param spacing Sample spacing in metres; positive.
45 /// @throws std::domain_error as `DegradationModel::State`.
46 std::vector<PreparedCrater>
47 PrepareCraters(const CraterList& craters, const CraterApplyOptions& options, double spacing,
48 const DegradationModel& degradation,
49 const std::function<void(const Crater&, CraterOutline&)>& reshape = {});
50
51 } // namespace terraingen
52