./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
32 / 32
100.0%
Branches:
5 / 7
71.4%
Functions:
1 / 1, 3 excl
100.0%

include/terraingen/layers/craters/profiles/profile.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief `CraterProfile`, a crater's height as a function of distance from its center.
5 #pragma once
6
7 #include "terraingen/layers/craters/degradation/state.h"
8 #include "terraingen/layers/kernels/craters.h"
9
10 namespace terraingen {
11
12 /// The topography of a crater: height relative to the pre-impact surface by distance from
13 /// the center, for a degradation state.
14 1651 class CraterProfile {
15 public:
16
3/5
<unknown function 14>:
✓ Branch 1 taken 1 time.
<unknown function 16>:
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
1261 virtual ~CraterProfile() = default;
17
18 /// The height (m) relative to the surface the crater formed on, at `distance` meters from the
19 /// center of a crater `diameter` meters rim to rim.
20 virtual double Height(double distance, double diameter, const CraterState& state) const = 0;
21
22 /// The distance in crater radii beyond which `Height` is zero.
23 virtual double ReachRadii() const = 0;
24
25 /// Whether a crater of `diameter` meters has the complex form (flat floor, terraced walls,
26 /// central peak); false by default.
27 6897764 virtual bool IsComplex(double /*diameter*/) const {
28 6897764 return false;
29 }
30 };
31
32 /// The kernel record of a crater of `diameter` meters in `state`, the shape fields only, as the
33 /// profile kernels read it.
34 22693667 inline CraterRecord KernelStateRecord(double diameter, const CraterState& state) {
35 22693667 CraterRecord r;
36 22693667 r.diameter = static_cast<float>(diameter);
37 22693667 r.freshDepth = static_cast<float>(state.fresh.depthRatio);
38 22693667 r.freshRim = static_cast<float>(state.fresh.rimHeightRatio);
39 22693667 r.currentDepth = static_cast<float>(state.current.depthRatio);
40 22693667 r.currentRim = static_cast<float>(state.current.rimHeightRatio);
41 22693667 r.diffusion = static_cast<float>(state.diffusion);
42
2/2
✓ Branch 0 taken 109293 times.
✓ Branch 1 taken 234310 times.
22693667 return r;
43 }
44
45 } // namespace terraingen
46