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

include/terraingen/layers/craters/degradation/freshness_degradation.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief `FreshnessDegradation`, craters degraded linearly with the share of their lifetime left.
5 #pragma once
6
7 #include "terraingen/layers/craters/ages/age_model.h"
8 #include "terraingen/layers/craters/degradation/degradation_model.h"
9
10 #include <memory>
11
12 namespace terraingen {
13
14 /// Scales fresh depth and rim height by e = c + (1 - c) * `RemainingLifetime`, with c
15 /// making a crater at the end of its lifetime exactly `cutoffDepthRatio` deep; a crater already
16 /// shallower than that when fresh, such as a large basin, keeps its fresh shape.
17 class FreshnessDegradation final : public DegradationModel {
18 public:
19 /// @param cutoffDepthRatio Depth over diameter at the end of a crater's lifetime.
20 /// @throws std::invalid_argument if `ages` is null, `fresh` empty, or `cutoffDepthRatio` not
21 /// in (0, 0.1).
22 FreshnessDegradation(std::shared_ptr<const CraterAgeModel> ages, FreshMorphometry fresh,
23 double cutoffDepthRatio = kVisibilityDepthRatio);
24
25 /// The crater's fresh morphometry, and that scaled by the erosion factor at its age.
26 /// @throws std::domain_error as `CraterAgeModel::LifetimeGyr`.
27 CraterState State(const Crater& crater) const override;
28
29 /// The ages whose lifetimes the craters wear over.
30 4 std::shared_ptr<const CraterAgeModel> AgeModel() const override {
31
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 return m_ages;
32 }
33
34 private:
35 std::shared_ptr<const CraterAgeModel> m_ages;
36 FreshMorphometry m_fresh;
37 double m_cutoffDepthRatio;
38 };
39
40 } // namespace terraingen
41