./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
165 / 176
93.8%
Branches:
332 / 354
93.8%
Functions:
12 / 12, 8 excl
100.0%

include/terraingen/layers/craters/crater.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief `Crater` and `CraterList`, and `CraterSelection`, which of them a model applies to.
5 #pragma once
6
7 #include "terraingen/noise/hash.h"
8
9 #include <cmath>
10 #include <cstddef>
11 #include <cstdint>
12 #include <functional>
13 #include <initializer_list>
14 #include <limits>
15 #include <optional>
16 #include <string_view>
17 #include <vector>
18
19 namespace terraingen {
20
21 /// `value`, unset when NaN, as a column of optional values holds it.
22 19706276 inline std::optional<double> UnlessNan(double value) {
23
4/4
✓ Branch 0 taken 9852254 times.
✓ Branch 1 taken 884 times.
✓ Branch 2 taken 9853150 times.
✓ Branch 3 taken 1 time.
9853140 return std::isnan(value) ? std::nullopt : std::optional<double>(value);
24 }
25
26 /// One crater: center in surface coordinates, rim-to-rim diameter, age and a stable ID, and for a
27 /// manual crater optionally its depth and rim height.
28 77458 struct Crater {
29 double x = 0.0; ///< Surface x of the center.
30 double y = 0.0; ///< Surface y of the center.
31 double diameter = 0.0; ///< Rim-to-rim diameter (m).
32 double ageGyr = 0.0; ///< Age (Gyr).
33 std::uint64_t id = 0; ///< Stable ID.
34 /// Placed by hand, identified in imagery or read from a catalog rather than generated; takes
35 /// precedence over generated craters and is never removed by spacing.
36 bool manual = false;
37 /// Rim-to-floor depth (m) of a manual crater; unset takes it from the degradation model.
38 std::optional<double> depth{};
39 /// Rim crest above the pre-impact surface (m) of a manual crater with a `depth`; unset derives
40 /// it from the depth (`ResolvedCraterState`).
41 std::optional<double> rimHeight{};
42 /// Replaces whatever the terrain holds where it lies with a sharp crater cut into a datum
43 /// fitted around it (`CraterReplacement`), such as a crater a DEM holds blurred. It stands in
44 /// for a crater the terrain held, so selections take it as generated (`CraterSelection`): it
45 /// gets the irregular outline, secondaries and albedo generated craters get.
46 bool replace = false;
47
48 /// Sets the age in Gyr, for chaining after `ManualCrater`.
49 Crater& AgeGyr(double gyr) {
50 ageGyr = gyr;
51 return *this;
52 }
53 /// Sets the rim-to-floor depth in meters.
54 11 Crater& Depth(double meters) {
55 9 depth = meters;
56
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 1 time.
10 return *this;
57 }
58 /// Sets the rim crest above the pre-impact surface in meters; needs a `depth`.
59 1 Crater& RimHeight(double meters) {
60 1 rimHeight = meters;
61 1 return *this;
62 }
63 /// Sets whether the crater replaces the terrain beneath it.
64 52 Crater& Replace(bool replaces = true) {
65 58 replace = replaces;
66
1/1
✓ Branch 1 taken 48 times.
52 return *this;
67 }
68
69 463991 bool operator==(const Crater& other) const {
70
3/4
✓ Branch 0 taken 201085 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201084 times.
✓ Branch 3 taken 1 time.
201069 return x == other.x && y == other.y && diameter == other.diameter &&
71
4/6
✓ Branch 0 taken 200919 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 201047 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 201067 times.
✗ Branch 5 not taken.
201084 ageGyr == other.ageGyr && id == other.id && manual == other.manual &&
72
8/8
✓ Branch 0 taken 201069 times.
✓ Branch 1 taken 262922 times.
✓ Branch 2 taken 201081 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 201040 times.
✓ Branch 5 taken 41 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 201039 times.
1067179 depth == other.depth && rimHeight == other.rimHeight && replace == other.replace;
73 }
74 3 bool operator!=(const Crater& other) const {
75
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 return !(*this == other);
76 }
77 };
78
79 /// A stable ID for a manual crater that has none, hashed with `Philox4x32`: the same for the same
80 /// crater in every run.
81 /// @param diameter In meters.
82 std::uint64_t ManualCraterId(double x, double y, double diameter);
83
84 /// A fresh crater placed by hand at (`x`, `y`), `diameter` meters across, flagged `manual`, with
85 /// its ID left 0 for the layer to hash; set the rest by name:
86 ///
87 /// ManualCrater(-4.0, 3.0, 9.0).AgeGyr(0.5).Depth(1.8)
88 51 inline Crater ManualCrater(double x, double y, double diameter) {
89 51 Crater crater;
90 51 crater.x = x;
91 51 crater.y = y;
92 51 crater.diameter = diameter;
93 51 crater.manual = true;
94
13/14
<unknown function 54>:
✓ Branch 1 taken 1 time.
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
<unknown function 88>:
✓ Branch 1 taken 3 times.
✓ Branch 1 taken 23 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 4 taken 1 time.
terraingen::Crater::operator==(terraingen::Crater const&) const:
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 14 taken 1 time.
51 return crater;
95 }
96
97 /// The 32-bit key that seeds crater `id`'s noise or texture under `seed`, the same on the CPU and
98 /// the GPU, which is handed it.
99 692457 constexpr std::uint32_t CraterKey(std::uint64_t id, std::uint32_t seed) {
100
2/2
✓ Branch 0 taken 164231 times.
✓ Branch 1 taken 179372 times.
348854 return HashWord64(id, seed);
101 }
102
103 /// Craters stored as one array per field, so each column can be shared with NumPy or a GPU
104 /// without copying.
105 class CraterList {
106 public:
107 /// An empty list.
108 3441841 CraterList() = default;
109
110 /// A list of `craters`, in order.
111 CraterList(std::initializer_list<Crater> craters);
112
113 /// The number of craters.
114 17018271 std::size_t Size() const {
115
172/175
<unknown function 114>:
✓ Branch 0 taken 7695 times.
✓ Branch 1 taken 141 times.
✓ Branch 1 taken 1551 times.
✓ Branch 3 taken 21538 times.
✓ Branch 4 taken 126 times.
<unknown function 22>:
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 9853136 times.
✓ Branch 2 taken 75602 times.
✓ Branch 3 taken 293218 times.
<unknown function 88>:
✓ Branch 1 taken 1 time.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 10726 times.
✓ Branch 4 taken 1 time.
<unknown function 99>:
✓ Branch 0 taken 43850 times.
✓ Branch 1 taken 1387 times.
terraingen::CraterList::CraterList():
✓ Branch 0 taken 1338208 times.
✓ Branch 1 taken 264825 times.
✓ Branch 1 taken 300681 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 2 taken 848943 times.
✓ Branch 3 taken 72477 times.
✓ Branch 3 taken 35378 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 128637 times.
✓ Branch 4 taken 385 times.
✓ Branch 4 taken 65 times.
✓ Branch 4 taken 33961 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 408 times.
✓ Branch 5 taken 90225 times.
✓ Branch 5 taken 99248 times.
✓ Branch 6 taken 4712 times.
✓ Branch 6 taken 3 times.
✓ Branch 6 taken 849 times.
✓ Branch 6 taken 770 times.
✓ Branch 7 taken 8 times.
✓ Branch 7 taken 2 times.
✓ Branch 7 taken 1 time.
✓ Branch 7 taken 1774400 times.
✓ Branch 8 taken 142 times.
✓ Branch 8 taken 4136 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 2 times.
✓ Branch 9 taken 138 times.
✓ Branch 9 taken 1470 times.
✓ Branch 9 taken 37 times.
✓ Branch 9 taken 600 times.
✓ Branch 10 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 10 taken 195 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 387 times.
✓ Branch 11 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 12 taken 2 times.
✓ Branch 12 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 264509 times.
✓ Branch 13 taken 348 times.
✓ Branch 14 taken 1 time.
✓ Branch 14 taken 26236 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 1 time.
✓ Branch 15 taken 53 times.
✓ Branch 15 taken 180 times.
✓ Branch 15 taken 1 time.
✓ Branch 16 taken 264728 times.
✓ Branch 16 taken 1 time.
✓ Branch 17 taken 166 times.
✓ Branch 17 taken 1 time.
✓ Branch 17 taken 2 times.
✓ Branch 18 taken 1 time.
✓ Branch 18 taken 1 time.
✓ Branch 18 taken 2 times.
✓ Branch 18 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 20 taken 7900 times.
✓ Branch 20 taken 1 time.
✓ Branch 21 taken 1 time.
✓ Branch 21 taken 4 times.
✓ Branch 22 taken 34 times.
✓ Branch 22 taken 9349 times.
✓ Branch 23 taken 1 time.
✓ Branch 23 taken 10 times.
✓ Branch 23 taken 1 time.
✓ Branch 24 taken 10275 times.
✓ Branch 24 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 25 taken 3 times.
✓ Branch 26 taken 1 time.
✓ Branch 27 taken 1 time.
✓ Branch 27 taken 1 time.
✓ Branch 27 taken 2531 times.
✓ Branch 28 taken 3 times.
✓ Branch 29 taken 135 times.
✓ Branch 30 taken 1 time.
✓ Branch 30 taken 1 time.
✓ Branch 30 taken 3 times.
✓ Branch 32 taken 68 times.
✓ Branch 32 taken 1 time.
✓ Branch 33 taken 1 time.
✓ Branch 33 taken 1 time.
✓ Branch 33 taken 1 time.
✓ Branch 35 taken 28 times.
✓ Branch 35 taken 1 time.
✓ Branch 35 taken 1125 times.
✓ Branch 36 taken 1 time.
✓ Branch 36 taken 1 time.
✓ Branch 37 taken 11 times.
✓ Branch 37 taken 51 times.
✓ Branch 38 taken 1 time.
✓ Branch 38 taken 2 times.
✓ Branch 39 taken 510 times.
✓ Branch 40 taken 1 time.
✓ Branch 40 taken 4 times.
✓ Branch 41 taken 1 time.
✓ Branch 41 taken 43 times.
✓ Branch 42 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 43 taken 3140 times.
✓ Branch 44 taken 3 times.
✓ Branch 44 taken 1 time.
✓ Branch 46 taken 1 time.
✓ Branch 46 taken 1 time.
✓ Branch 46 taken 230 times.
✓ Branch 47 taken 1 time.
✓ Branch 49 taken 1 time.
✓ Branch 49 taken 1 time.
✓ Branch 52 taken 1 time.
✓ Branch 52 taken 1 time.
✓ Branch 54 taken 1727 times.
✓ Branch 55 taken 1 time.
✓ Branch 55 taken 4 times.
✓ Branch 57 taken 1 time.
✓ Branch 58 taken 1 time.
✓ Branch 59 taken 264425 times.
✓ Branch 60 taken 1064 times.
✓ Branch 61 taken 1 time.
✓ Branch 61 taken 1064 times.
✓ Branch 62 taken 3 times.
✓ Branch 64 taken 2 times.
✓ Branch 67 taken 1 time.
✓ Branch 67 taken 1 time.
✓ Branch 69 taken 342 times.
✓ Branch 70 taken 1 time.
✓ Branch 70 taken 2 times.
✓ Branch 72 taken 1 time.
✓ Branch 73 taken 1 time.
✓ Branch 75 taken 1 time.
✓ Branch 75 taken 387 times.
✓ Branch 76 taken 1 time.
✓ Branch 78 taken 1 time.
✓ Branch 78 taken 1 time.
✓ Branch 80 taken 6318 times.
✓ Branch 80 taken 1 time.
✓ Branch 81 taken 1 time.
✗ Branch 81 not taken.
✓ Branch 83 taken 1 time.
✓ Branch 85 taken 5918 times.
✓ Branch 86 taken 5 times.
✓ Branch 88 taken 6 times.
✓ Branch 90 taken 77428 times.
✓ Branch 91 taken 14 times.
terraingen::CraterList::Size() const:
✓ Branch 0 taken 12402 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 373 times.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
16460768 return m_id.size();
116 }
117
118 /// Whether the list holds no crater.
119 3907558 bool Empty() const {
120
12/14
<unknown function 114>:
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 2845 times.
✓ Branch 2 taken 75762 times.
✓ Branch 3 taken 58710 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 488 times.
terraingen::CraterList::CraterList():
✓ Branch 0 taken 22278 times.
✓ Branch 0 taken 966 times.
✗ Branch 0 not taken.
✓ Branch 1 taken 3745210 times.
✓ Branch 1 taken 10 times.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
3907558 return m_id.empty();
121 }
122
123 /// Reserves room for `count` craters in every column.
124 void Reserve(std::size_t count);
125
126 /// Appends a crater.
127 void Append(const Crater& crater);
128
129 /// Appends every crater of `other`, in its order.
130 void Append(const CraterList& other);
131
132 /// The crater at `index`.
133 /// @throws std::out_of_range if `index` >= `Size()`.
134 Crater At(std::size_t index) const;
135
136 /// Surface x of every center.
137 52 const std::vector<double>& X() const {
138
6/7
<unknown function 114>:
✗ Branch 1 not taken.
terraingen::CraterList::CraterList():
✓ Branch 1 taken 1 time.
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
terraingen::CraterList::Size() const:
✓ Branch 1 taken 44 times.
6457018 return m_x;
139 }
140
141 /// Surface y of every center.
142 1832508 const std::vector<double>& Y() const {
143
3/4
<unknown function 114>:
✗ Branch 1 not taken.
terraingen::CraterList::CraterList():
✓ Branch 1 taken 3871855 times.
✓ Branch 2 taken 2585111 times.
terraingen::CraterList::Size() const:
✓ Branch 1 taken 44 times.
8289474 return m_y;
144 }
145
146 /// Every diameter, in meters.
147 128745 const std::vector<double>& Diameters() const {
148
11/12
<unknown function 114>:
✗ Branch 1 not taken.
terraingen::CraterList::CraterList():
✓ Branch 1 taken 1 time.
✓ Branch 1 taken 3871855 times.
✓ Branch 1 taken 1 time.
✓ Branch 1 taken 3 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2585111 times.
✓ Branch 4 taken 3 times.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
terraingen::CraterList::Size() const:
✓ Branch 1 taken 44 times.
6663182 return m_diameter;
149 }
150
151 /// Every age, in Gyr.
152 49 const std::vector<double>& AgesGyr() const {
153
3/4
<unknown function 114>:
✗ Branch 1 not taken.
terraingen::CraterList::CraterList():
✓ Branch 1 taken 1 time.
✓ Branch 1 taken 4 times.
terraingen::CraterList::Size() const:
✓ Branch 1 taken 44 times.
77507 return m_ageGyr;
154 }
155
156 /// Every ID.
157 83 const std::vector<std::uint64_t>& Ids() const {
158
18/19
<unknown function 114>:
✗ Branch 1 not taken.
terraingen::CraterList::CraterList():
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 1 time.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 1 time.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 1 time.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 1 time.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
terraingen::CraterList::Size() const:
✓ Branch 1 taken 44 times.
77543 return m_id;
159 }
160
161 /// 1 for manual craters, 0 for generated ones; bytes so it can be shared without copying.
162 46 const std::vector<std::uint8_t>& Manual() const {
163
4/5
<unknown function 114>:
✗ Branch 1 not taken.
terraingen::CraterList::CraterList():
✓ Branch 0 taken 4710 times.
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 1 time.
terraingen::CraterList::Size() const:
✓ Branch 1 taken 44 times.
4757 return m_manual;
164 }
165
166 /// Every explicit depth in meters (`Crater::depth`), NaN where it comes from the model.
167 2 const std::vector<double>& Depths() const {
168 2 return m_depth;
169 }
170
171 /// Every explicit rim height in meters (`Crater::rimHeight`), NaN where it is derived.
172 1 const std::vector<double>& RimHeights() const {
173 1 return m_rimHeight;
174 }
175
176 /// 1 for craters that replace the terrain beneath them (`Crater::replace`), 0 for others.
177 814 const std::vector<std::uint8_t>& Replace() const {
178
3/4
<unknown function 114>:
✗ Branch 1 not taken.
terraingen::CraterList::CraterList():
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 718 times.
terraingen::CraterList::Size() const:
✓ Branch 2 taken 44 times.
814 return m_replace;
179 }
180
181 /// Whether any crater replaces the terrain beneath it.
182 bool AnyReplace() const;
183
184 private:
185 std::vector<double> m_x;
186 std::vector<double> m_y;
187 std::vector<double> m_diameter;
188 std::vector<double> m_ageGyr;
189 std::vector<std::uint64_t> m_id;
190 std::vector<std::uint8_t> m_manual;
191 std::vector<double> m_depth;
192 std::vector<double> m_rimHeight;
193 std::vector<std::uint8_t> m_replace;
194 };
195
196 /// The craters `keep(index, crater)` keeps, in their order.
197 1172 template <typename Keep> CraterList FilterCraters(const CraterList& craters, const Keep& keep) {
198
7/7
terraingen::CraterList terraingen::FilterCraters<FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 2 taken 1 time.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 2 taken 52 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 2 taken 2 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 2 taken 36 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 2 taken 1067 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 2 taken 10 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 2 taken 4 times.
1172 CraterList kept;
199
7/7
terraingen::CraterList terraingen::FilterCraters<FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 1 time.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 52 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 2 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 36 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 1067 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 10 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 4 times.
1172 kept.Reserve(craters.Size());
200
14/14
terraingen::CraterList terraingen::FilterCraters<FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 time.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 514195 times.
✓ Branch 1 taken 52 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 2422 times.
✓ Branch 1 taken 2 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 29274 times.
✓ Branch 1 taken 36 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 9029 times.
✓ Branch 1 taken 1067 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 10 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 4 times.
556287 for (std::size_t n = 0; n < craters.Size(); ++n) {
201
7/7
terraingen::CraterList terraingen::FilterCraters<FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 5 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 514195 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 2422 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 29274 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 9029 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 179 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 11 times.
555115 const Crater crater = craters.At(n);
202
15/15
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 514195 times.
✓ Branch 3 taken 514179 times.
✓ Branch 4 taken 16 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 2361 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 29274 times.
✓ Branch 3 taken 15876 times.
✓ Branch 4 taken 13398 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 6895 times.
✓ Branch 1 taken 2134 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 179 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 132 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
555115 if (keep(n, crater)) {
203
7/7
terraingen::CraterList terraingen::FilterCraters<FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, FilterCraters_KeepsWhatThePredicateAcceptsInOrder_Test::TestBody()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 3 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::CropToRegion(terraingen::CraterList const&, unsigned long) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 514179 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::KeepLargest(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 61 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::(anonymous namespace)::Generation::RemoveSpacingConflicts(terraingen::CraterList const&, unsigned long&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 15876 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::BoulderLayer::EjectaCraters(terraingen::Bounds2d const&) const::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 6895 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::CraterLayer::FollowSource()::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 47 times.
terraingen::CraterList terraingen::FilterCraters<terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1}>(terraingen::CraterList const&, terraingen::ThinBySpacing(terraingen::CraterList const&, terraingen::CraterSpacing const&, terraingen::Surface const&)::{lambda(unsigned long, terraingen::Crater const&)#1} const&):
✓ Branch 1 taken 7 times.
537068 kept.Append(crater);
204 }
205 }
206 1172 return kept;
207 }
208
209 /// Appends `manual` to `craters`, flagged manual and given a `ManualCraterId` where their ID is 0.
210 /// @param keep Which craters to append; empty for all.
211 /// @throws std::invalid_argument for any crater, kept or not, with a field outside the range its
212 /// comment gives, or a rim height without a depth.
213 void AppendManualCraters(const CraterList& manual, CraterList& craters,
214 const std::function<bool(const Crater&)>& keep = {});
215
216 /// Which craters a model applies to, by diameter, age and whether manual.
217 8 struct CraterSelection {
218 double minDiameter = 0.0; ///< Smallest diameter (m).
219 double maxDiameter = std::numeric_limits<double>::infinity(); ///< Largest diameter (m).
220 double minAgeGyr = 0.0; ///< Youngest age (Gyr).
221 double maxAgeGyr = std::numeric_limits<double>::infinity(); ///< Oldest age (Gyr).
222 /// Whether manual craters are included; replacing craters (`Crater::replace`), which stand in
223 /// for craters the terrain held, are selected as generated craters are either way.
224 bool manual = true;
225
226 /// Whether a crater is selected: not for a manual crater that does not replace without
227 /// `manual`, or a diameter or age outside its range.
228 bool Includes(const Crater& crater) const;
229
230 /// Memberwise equality.
231 5 bool operator==(const CraterSelection& other) const {
232
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 return minDiameter == other.minDiameter && maxDiameter == other.maxDiameter &&
233
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
10 minAgeGyr == other.minAgeGyr && maxAgeGyr == other.maxAgeGyr &&
234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 manual == other.manual;
235 }
236 bool operator!=(const CraterSelection& other) const {
237 return !(*this == other);
238 }
239 };
240
241 /// Checks a crater selection.
242 /// @param what What the selection is for, which starts the error message.
243 /// @throws std::invalid_argument "<what> size and age ranges must satisfy 0 <= min <= max"
244 /// otherwise.
245 void ValidateCraterSelection(const CraterSelection& selection, std::string_view what);
246
247 } // namespace terraingen
248