106 void set_outlets(
const std::vector<glm::ivec2> &outlet_indices);
145 const Array &erodibility,
157 const Array &max_slope);
180 std::unordered_map<glm::ivec2, std::vector<glm::ivec2>,
IVec2Hash>
191 const int di[8] = {1, 1, 0, -1, -1, -1, 0, 1};
192 const int dj[8] = {0, -1, -1, -1, 0, 1, 1, 1};
194 {1.f, M_SQRT1_2, 1.f, M_SQRT1_2, 1.f, M_SQRT1_2, 1.f, M_SQRT1_2};
205 const Mat<glm::ivec2> &receivers);
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
Represents a cell-based hydrology drainage basin network on a 2D heightmap grid.
Definition drainage_basin_cell_based.hpp:41
void compute_receivers(unsigned int seed=0, float noise_strength=0.f)
Compute flow receivers using standard D8, with optional noise.
Definition drainage_basin_cell_based.cpp:59
std::vector< std::vector< glm::ivec2 > > get_main_channels() const
Get the main channel paths of the flow network.
Definition drainage_basin_cell_based.cpp:326
std::unordered_map< glm::ivec2, std::vector< glm::ivec2 >, IVec2Hash > traversals
Definition drainage_basin_cell_based.hpp:181
std::vector< glm::ivec2 > get_outlets() const
Get the outlets of the basin.
Definition drainage_basin_cell_based.cpp:364
Mat< glm::ivec2 > receivers
Grid of receiver coordinates.
Definition drainage_basin_cell_based.hpp:175
void update_stream_tree()
Update the stream tree deterministically.
Definition drainage_basin_cell_based.cpp:552
std::vector< std::vector< glm::ivec2 > > compute_upstream_traversals()
Compute upstream traversal orders for the entire grid.
Definition drainage_basin_cell_based.cpp:215
void compute_receivers_priority_flood()
Compute flow receivers using the priority flood routing algorithm.
Definition drainage_basin_cell_based.cpp:110
Array z
The heightmap array.
Definition drainage_basin_cell_based.hpp:172
Array compute_response_times(const Array &area_acc, const Array &erodibility, float m_exp) const
Compute response times of the basin cells.
Definition drainage_basin_cell_based.cpp:178
void accumulate_area_by_outlet(Array &acc) const
Accumulate contributing area down the network by outlet.
Definition drainage_basin_cell_based.cpp:38
Mat< std::vector< glm::ivec2 > > children
Grid of children coordinates.
Definition drainage_basin_cell_based.hpp:176
void remove_lakes(const Mat< glm::ivec2 > &subroot)
Remove lakes by draining local depressions.
Definition drainage_basin_cell_based.cpp:383
Mat< int > outlets_mask
Mask indicating outlet cells.
Definition drainage_basin_cell_based.hpp:174
void flow_breach()
Perform flow breaching to resolve depressions.
Definition drainage_basin_cell_based.cpp:299
void set_outlets(const std::vector< glm::ivec2 > &outlet_indices)
Set the outlets of the basin.
Definition drainage_basin_cell_based.cpp:481
const Array & get_z() const
Get the underlying heightmap array.
Definition drainage_basin_cell_based.cpp:378
float update_elevations(const Array &response_times, float uplift_rate, const Array &max_slope)
Update elevations based on response times and uplift.
Definition drainage_basin_cell_based.cpp:491
void update_traversals()
Update cached traversal orders for upstream/downstream computations.
Definition drainage_basin_cell_based.cpp:557
const glm::ivec2 null_cell
Constant representing an.
Definition drainage_basin_cell_based.hpp:186
DrainageBasinCellBased()=default
Default constructor.
Mat< glm::ivec2 > roots
Grid of basin root.
Definition drainage_basin_cell_based.hpp:177
std::pair< Mat< glm::ivec2 >, bool > find_subroots()
Find subroots of the flow network.
Definition drainage_basin_cell_based.cpp:248
Definition algebra.hpp:23
FlowDirectionMethod
Enumeration of available algorithms for computing flow directions.
Definition drainage_basin_cell_based.hpp:26
@ FDM_PRIORITY_FLOOD
Priority flood flow routing algorithm.
Definition drainage_basin_cell_based.hpp:28
@ FDM_D8
Standard D8 flow direction algorithm.
Definition drainage_basin_cell_based.hpp:27
Mat< std::vector< glm::ivec2 > > invert_receiver_map(const Mat< glm::ivec2 > &receivers)
Invert the receiver map to build a map of children/downstream receivers.
Definition drainage_basin_cell_based.cpp:587
Definition algebra.hpp:31
Mat class for basic manipulation of 2D matrices.
Definition algebra.hpp:92