FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
ParametricBathymetry.h
1#pragma once
2
3#include <marenv/seafloor/BathymetryField.h>
4
5#include <memory>
6#include <string>
7#include <vector>
8
10namespace environmentmodels
11{
12
14namespace parametric
15{
16
24enum class Primitive
25{
26 Constant,
27 Slope,
29 Valley,
30 Peak,
31 Bump,
33};
34
36enum class InterpMode
37{
38 Linear,
41};
42
44enum class Extrap
45{
46 Flat,
47 Linear,
48 Extend
49};
50
57{
60 std::vector<double> nodes;
61 std::vector<double> values;
62
63 // Precomputed coefficients (populated by the builder in the .cpp).
64 std::vector<double> poly;
65 std::vector<double> b;
66 std::vector<double> c;
67 std::vector<double> d;
68
74 [[nodiscard]] double Evaluate(double v) const;
75};
76
78enum class Shape
79{
80 Gaussian,
81 Parabola,
82 Cosine
83};
84
86enum class Window
87{
88 Hard,
89 Linear,
92};
93
95enum class Blend
96{
97 Replace,
98 Add,
99 Min,
100 Max
101};
102
108{
110 double headingRad = 0.0;
111 double depth = 200.0;
112 double gradient = 0.0;
113 double amplitude = 0.0;
114 double width = 1.0;
115 double crossOffset = 0.0;
116 double centerX = 0.0;
117 double centerY = 0.0;
119
120 std::shared_ptr<const Profile1D> profile;
121};
122
128struct Region
129{
130 double headingRad = 0.0;
131 double min = -1.0e300;
132 double max = 1.0e300;
134 double falloff = 0.0;
135};
136
144
147{
148 double length = 100.0;
150};
151
160struct Track
161{
162 bool present = false;
163 double headingRad = 0.0;
164 double start = 0.0;
165 double transitionWidth = 0.0;
167 std::vector<Segment> segments;
168};
169
171struct Spec
172{
173 double baseDepth = 200.0;
174 double rho = 2000.0;
176 std::vector<Layer> layers;
177};
178
179} // namespace parametric
180
200{
201public:
207 ~ParametricBathymetry() override = default;
208
215 static std::shared_ptr<ParametricBathymetry> FromJsonString(const std::string& jsonText);
216
223 static std::shared_ptr<ParametricBathymetry> FromFile(const std::string& path);
224
226 [[nodiscard]] marenv::Status GetDepth(const double pos[2], double& depthOut) override;
227
229 [[nodiscard]] marenv::Status ComputeSurfaceUnitNormal(const double pos[2], double unitNormalOut[3]) override;
230
232 [[nodiscard]] marenv::Status GetSeabedSigma(const double pos[3], double& sigmaOut) override;
233
235 [[nodiscard]] marenv::Status GetSeabedTau(const double pos[3], double& tauOut) override;
236
238 [[nodiscard]] marenv::Status GetSeabedRho(const double pos[3], double& rhoOut) override;
239
241 [[nodiscard]] marenv::Status ComputeRayIntersection(const double origin[3], const double direction[3],
242 double& distanceOut, double maxSearchDistance = 100.0, double startSearchDistance = -1.0,
243 double stepSize = 1.0, double convergenceTolerance = 0.01) override;
244
251 [[nodiscard]] double DepthAt(double x, double y) const;
252
253private:
254 double TrackDepth(double x, double y) const;
255
256 parametric::Spec m_spec;
257};
258
259} // namespace environmentmodels
Definition ParametricBathymetry.h:200
static std::shared_ptr< ParametricBathymetry > FromJsonString(const std::string &jsonText)
double DepthAt(double x, double y) const
static std::shared_ptr< ParametricBathymetry > FromFile(const std::string &path)
marenv::Status ComputeSurfaceUnitNormal(const double pos[2], double unitNormalOut[3]) override
marenv::Status GetDepth(const double pos[2], double &depthOut) override
marenv::Status ComputeRayIntersection(const double origin[3], const double direction[3], double &distanceOut, double maxSearchDistance=100.0, double startSearchDistance=-1.0, double stepSize=1.0, double convergenceTolerance=0.01) override
ParametricBathymetry(parametric::Spec spec)
marenv::Status GetSeabedTau(const double pos[3], double &tauOut) override
marenv::Status GetSeabedRho(const double pos[3], double &rhoOut) override
marenv::Status GetSeabedSigma(const double pos[3], double &sigmaOut) override
Definition BathymetryField.h:24
Status
Definition marenv.h:40
Extrap
Behaviour of a 1-D profile outside its node range.
Definition ParametricBathymetry.h:45
@ Extend
Continue the interpolant/polynomial itself (may diverge).
@ Flat
Clamp to the nearest end value (constant beyond the range).
Window
Spatial window (validity interval) edge profiles.
Definition ParametricBathymetry.h:87
@ Smoothstep
Cubic smoothstep ramp.
@ Hard
Discontinuous 0/1 gate.
@ RaisedCosine
Raised-cosine ramp (partition-of-unity between neighbours).
Shape
One-dimensional profile shapes used by Valley/Peak/Bump primitives.
Definition ParametricBathymetry.h:79
@ Cosine
for , else 0 (finite support).
Blend
How a layer's weighted primitive combines with the accumulated depth.
Definition ParametricBathymetry.h:96
@ Replace
Linear blend toward the primitive by the region weight.
@ Max
Blend toward the deeper (larger depth) of the two.
@ Min
Blend toward the shallower (smaller depth) of the two.
@ Add
Add the weighted primitive value.
InterpMode
Interpolation method for a 1-D transversal profile.
Definition ParametricBathymetry.h:37
@ Polynomial
Single canonical (monomial) polynomial through all points.
@ Linear
Piecewise linear through the points.
@ CubicSpline
Piecewise cubic spline (natural or clamped end slopes).
Primitive
Definition ParametricBathymetry.h:25
@ TransversalInterp
Cross-track profile interpolated through user-specified points.
@ Valley
Trough extruded along the heading (deeper toward the centre-line).
@ Peak
Ridge extruded along the heading (shallower toward the centre-line).
@ Bump
Localised radial feature centred at a point.
@ TransversalSlope
Inclined plane, gradient across the heading direction.
@ Slope
Inclined plane, gradient along the heading direction.
Environment SimObjects.
Definition Environment.h:25
Definition ParametricBathymetry.h:108
double width
Characteristic width [m] (Valley/Peak/Bump).
Definition ParametricBathymetry.h:114
Shape shape
Profile shape (Valley/Peak/Bump).
Definition ParametricBathymetry.h:118
double depth
Datum depth [m].
Definition ParametricBathymetry.h:111
double centerX
Bump centre, North [m].
Definition ParametricBathymetry.h:116
double amplitude
Feature amplitude [m] (Valley/Peak/Bump).
Definition ParametricBathymetry.h:113
double gradient
Slope [m/m] (Slope, TransversalSlope).
Definition ParametricBathymetry.h:112
double headingRad
Heading [rad], North toward East.
Definition ParametricBathymetry.h:110
std::shared_ptr< const Profile1D > profile
Interpolated cross-track profile (TransversalInterp).
Definition ParametricBathymetry.h:120
double crossOffset
Offset of the feature line [m].
Definition ParametricBathymetry.h:115
double centerY
Bump centre, East [m].
Definition ParametricBathymetry.h:117
Primitive type
Primitive kind.
Definition ParametricBathymetry.h:109
A primitive applied over a region, combined by a blend operator.
Definition ParametricBathymetry.h:139
Region region
Where it is active.
Definition ParametricBathymetry.h:141
Blend blend
How it combines with the accumulator.
Definition ParametricBathymetry.h:142
Feature feature
The primitive to apply.
Definition ParametricBathymetry.h:140
Definition ParametricBathymetry.h:57
std::vector< double > values
Node values z_i.
Definition ParametricBathymetry.h:61
std::vector< double > poly
Canonical polynomial coefficients (Polynomial).
Definition ParametricBathymetry.h:64
std::vector< double > b
Spline/linear 1st-order coefficients per node.
Definition ParametricBathymetry.h:65
std::vector< double > c
Spline 2nd-order coefficients per node.
Definition ParametricBathymetry.h:66
InterpMode mode
Interpolation method.
Definition ParametricBathymetry.h:58
std::vector< double > nodes
Node coordinates v_i (ascending).
Definition ParametricBathymetry.h:60
Extrap extrap
Out-of-range behaviour.
Definition ParametricBathymetry.h:59
std::vector< double > d
Spline 3rd-order coefficients per node.
Definition ParametricBathymetry.h:67
Definition ParametricBathymetry.h:129
double headingRad
Region axis heading [rad].
Definition ParametricBathymetry.h:130
double min
Interval lower bound along the region axis [m].
Definition ParametricBathymetry.h:131
double max
Interval upper bound along the region axis [m].
Definition ParametricBathymetry.h:132
Window window
Edge profile.
Definition ParametricBathymetry.h:133
double falloff
Transition band width [m].
Definition ParametricBathymetry.h:134
One along-track segment: a length and the cross-track profile it presents.
Definition ParametricBathymetry.h:147
Feature profile
Cross-track seabed profile for this segment.
Definition ParametricBathymetry.h:149
double length
Along-track extent [m].
Definition ParametricBathymetry.h:148
Definition ParametricBathymetry.h:172
double rho
Constant seabed density [kg/m^3].
Definition ParametricBathymetry.h:174
Track track
Optional along-track profile sequence.
Definition ParametricBathymetry.h:175
double baseDepth
Fallback depth where nothing else applies [m].
Definition ParametricBathymetry.h:173
std::vector< Layer > layers
Optional general composition layers (applied after the track).
Definition ParametricBathymetry.h:176
Definition ParametricBathymetry.h:161
double transitionWidth
Cross-fade width [m].
Definition ParametricBathymetry.h:165
std::vector< Segment > segments
Ordered segments.
Definition ParametricBathymetry.h:167
double start
Along-track position of the first segment [m].
Definition ParametricBathymetry.h:164
double headingRad
Track heading [rad], North toward East.
Definition ParametricBathymetry.h:163
bool present
Whether a track is configured.
Definition ParametricBathymetry.h:162
Window transition
Cross-fade edge profile.
Definition ParametricBathymetry.h:166