HighMap library (C++)
Loading...
Searching...
No Matches
hydrology.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
23#pragma once
24
25#include "highmap/array.hpp"
27
28namespace hmap
29{
30
46Array d8_compute_ndip(const Array &d8);
47
62void find_flow_sinks(const Array &z,
63 std::vector<int> &is,
64 std::vector<int> &js);
65
66Array flooding_from_point(const Array &z, const int i, const int j);
67
68Array flooding_from_point(const Array &z,
69 const std::vector<int> &i,
70 const std::vector<int> &j);
71
94Array flow_accumulation_d8(const Array &z);
95
122Array flow_accumulation_dinf(const Array &z, float talus_ref);
123
140Array flow_direction_d8(const Array &z);
141
159std::vector<Array> flow_direction_dinf(const Array &z, float talus_ref);
160
194Path flow_stream(const Array &z,
195 const Vec2<int> ij_start,
196 const float elevation_ratio = 0.5f,
197 const float distance_exponent = 2.f,
198 const float upward_penalization = 100.f);
199
246Array generate_riverbed(const Path &path,
247 Vec2<int> shape,
248 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f},
249 bool bezier_smoothing = false,
250 float depth_start = 0.01f,
251 float depth_end = 1.f,
252 float slope_start = 64.f,
253 float slope_end = 32.f,
254 float shape_exponent_start = 1.f,
255 float shape_exponent_end = 10.f,
256 float k_smoothing = 0.5f,
257 int post_filter_ir = 0,
258 Array *p_noise_x = nullptr,
259 Array *p_noise_y = nullptr,
260 Array *p_noise_r = nullptr);
261
262} // namespace hmap
263
264namespace hmap::gpu
265{
266
268Array flow_direction_d8(const Array &z);
269
271Array generate_riverbed(const Path &path,
272 Vec2<int> shape,
273 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f},
274 bool bezier_smoothing = false,
275 float depth_start = 0.01f,
276 float depth_end = 1.f,
277 float slope_start = 64.f,
278 float slope_end = 32.f,
279 float shape_exponent_start = 1.f,
280 float shape_exponent_end = 10.f,
281 float k_smoothing = 0.5f,
282 int post_filter_ir = 0,
283 Array *p_noise_x = nullptr,
284 Array *p_noise_y = nullptr,
285 Array *p_noise_r = nullptr);
286
287} // namespace hmap::gpu
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Definition blending.hpp:151
Array generate_riverbed(const Path &path, Vec2< int > shape, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f}, bool bezier_smoothing=false, float depth_start=0.01f, float depth_end=1.f, float slope_start=64.f, float slope_end=32.f, float shape_exponent_start=1.f, float shape_exponent_end=10.f, float k_smoothing=0.5f, int post_filter_ir=0, Array *p_noise_x=nullptr, Array *p_noise_y=nullptr, Array *p_noise_r=nullptr)
See hmap::generate_riverbed.
Definition generate_riverbed_gpu.cpp:16
Array flow_direction_d8(const Array &z)
See hmap::flow_direction_d8.
Definition flow_accumulation_d8_gpu.cpp:10
Definition algebra.hpp:28
Array flow_accumulation_d8(const Array &z)
Computes the flow accumulation for each cell using the D8 flow direction model.
Definition flow_accumulation_d8.cpp:49
Array d8_compute_ndip(const Array &d8)
Computes the number of drainage paths for each cell based on the D8 flow direction model.
Definition flow_accumulation_d8.cpp:27
Array flow_accumulation_dinf(const Array &z, float talus_ref)
Computes the flow accumulation for each cell using the Multiple Flow Direction (MFD) model.
Definition flow_accumulation_dinf.cpp:36
Path flow_stream(const Array &z, const Vec2< int > ij_start, const float elevation_ratio=0.5f, const float distance_exponent=2.f, const float upward_penalization=100.f)
Computes the optimal flow path from a starting point to the boundary of a given elevation array.
Definition flow_stream.cpp:46
std::vector< Array > flow_direction_dinf(const Array &z, float talus_ref)
Computes the flow direction and weights for each direction using the Multiple Flow Direction (MFD) mo...
Definition flow_accumulation_dinf.cpp:107
Array generate_riverbed(const Path &path, Vec2< int > shape, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f}, bool bezier_smoothing=false, float depth_start=0.01f, float depth_end=1.f, float slope_start=64.f, float slope_end=32.f, float shape_exponent_start=1.f, float shape_exponent_end=10.f, float k_smoothing=0.5f, int post_filter_ir=0, Array *p_noise_x=nullptr, Array *p_noise_y=nullptr, Array *p_noise_r=nullptr)
Generates a 2D array representing a riverbed based on a specified path.
Definition generate_riverbed.cpp:16
Array flooding_from_point(const Array &z, const int i, const int j)
Definition flooding_from_point.cpp:12
void find_flow_sinks(const Array &z, std::vector< int > &is, std::vector< int > &js)
Identifies the indices of flow sinks within the heightmap.
Definition find_flow_sinks.cpp:10
Array flow_direction_d8(const Array &z)
Computes the flow direction from each cell to its downslope neighbor using the D8 model.
Definition flow_accumulation_d8.cpp:100
Path class for manipulating and analyzing paths in 2D space.