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 | 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 |