HighMap library (C++)
Loading...
Searching...
No Matches
hmap::DrainageBasinCellBased Class Reference

Represents a cell-based hydrology drainage basin network on a 2D heightmap grid. More...

#include <drainage_basin_cell_based.hpp>

Collaboration diagram for hmap::DrainageBasinCellBased:

Public Member Functions

 DrainageBasinCellBased ()=default
 Default constructor.
 
 DrainageBasinCellBased (const Array &z_)
 Construct a new cell-based drainage basin using a heightmap.
 
const Arrayget_z () const
 Get the underlying heightmap array.
 
void compute_receivers (unsigned int seed=0, float noise_strength=0.f)
 Compute flow receivers using standard D8, with optional noise.
 
void compute_receivers_priority_flood ()
 Compute flow receivers using the priority flood routing algorithm.
 
void update_stream_tree (unsigned int seed, float noise_strength)
 Update the stream tree stochastically.
 
void update_stream_tree ()
 Update the stream tree deterministically.
 
void update_traversals ()
 Update cached traversal orders for upstream/downstream computations.
 
std::vector< glm::ivec2 > get_outlets () const
 Get the outlets of the basin.
 
void set_outlets (const std::vector< glm::ivec2 > &outlet_indices)
 Set the outlets of the basin.
 
std::vector< std::vector< glm::ivec2 > > compute_upstream_traversals ()
 Compute upstream traversal orders for the entire grid.
 
std::pair< Mat< glm::ivec2 >, bool > find_subroots ()
 Find subroots of the flow network.
 
void remove_lakes (const Mat< glm::ivec2 > &subroot)
 Remove lakes by draining local depressions.
 
std::vector< std::vector< glm::ivec2 > > get_main_channels () const
 Get the main channel paths of the flow network.
 
Array compute_response_times (const Array &area_acc, const Array &erodibility, float m_exp) const
 Compute response times of the basin cells.
 
float update_elevations (const Array &response_times, float uplift_rate, const Array &max_slope)
 Update elevations based on response times and uplift.
 
void accumulate_area_by_outlet (Array &acc) const
 Accumulate contributing area down the network by outlet.
 
void flow_breach ()
 Perform flow breaching to resolve depressions.
 

Public Attributes

Array z
 The heightmap array.
 
Mat< int > outlets_mask
 Mask indicating outlet cells.
 
Mat< glm::ivec2 > receivers
 Grid of receiver coordinates.
 
Mat< std::vector< glm::ivec2 > > children
 Grid of children coordinates.
 
Mat< glm::ivec2 > roots
 Grid of basin root.
 
std::unordered_map< glm::ivec2, std::vector< glm::ivec2 >, IVec2Hashtraversals
 
const glm::ivec2 null_cell = glm::ivec2(-1, -1)
 Constant representing an.
 

Detailed Description

Represents a cell-based hydrology drainage basin network on a 2D heightmap grid.

This class implements hydrological flow network computations (receivers, outlets, main channels, upstream traversals) on a regular grid represented by a 2D Array.

Constructor & Destructor Documentation

◆ DrainageBasinCellBased() [1/2]

hmap::DrainageBasinCellBased::DrainageBasinCellBased ( )
default

Default constructor.

◆ DrainageBasinCellBased() [2/2]

hmap::DrainageBasinCellBased::DrainageBasinCellBased ( const Array z_)

Construct a new cell-based drainage basin using a heightmap.

Parameters
z_The input heightmap array.

Member Function Documentation

◆ get_z()

const Array & hmap::DrainageBasinCellBased::get_z ( ) const

Get the underlying heightmap array.

Returns
A const reference to the heightmap Array.

◆ compute_receivers()

void hmap::DrainageBasinCellBased::compute_receivers ( unsigned int  seed = 0,
float  noise_strength = 0.f 
)

Compute flow receivers using standard D8, with optional noise.

Parameters
seedSeed for random generation.
noise_strengthStrength of elevation noise added for stochastic flow paths.

◆ compute_receivers_priority_flood()

void hmap::DrainageBasinCellBased::compute_receivers_priority_flood ( )

Compute flow receivers using the priority flood routing algorithm.

◆ update_stream_tree() [1/2]

void hmap::DrainageBasinCellBased::update_stream_tree ( unsigned int  seed,
float  noise_strength 
)

Update the stream tree stochastically.

Parameters
seedSeed for random generation.
noise_strengthStrength of noise.

◆ update_stream_tree() [2/2]

void hmap::DrainageBasinCellBased::update_stream_tree ( )

Update the stream tree deterministically.

◆ update_traversals()

void hmap::DrainageBasinCellBased::update_traversals ( )

Update cached traversal orders for upstream/downstream computations.

◆ get_outlets()

std::vector< glm::ivec2 > hmap::DrainageBasinCellBased::get_outlets ( ) const

Get the outlets of the basin.

Returns
A vector of 2D grid coordinates of the outlets.

◆ set_outlets()

void hmap::DrainageBasinCellBased::set_outlets ( const std::vector< glm::ivec2 > &  outlet_indices)

Set the outlets of the basin.

Parameters
outlet_indicesVector of outlet 2D coordinates.

◆ compute_upstream_traversals()

std::vector< std::vector< glm::ivec2 > > hmap::DrainageBasinCellBased::compute_upstream_traversals ( )

Compute upstream traversal orders for the entire grid.

Returns
A vector of paths, each represented as a vector of 2D coordinates.

◆ find_subroots()

std::pair< Mat< glm::ivec2 >, bool > hmap::DrainageBasinCellBased::find_subroots ( )

Find subroots of the flow network.

Returns
A pair containing a matrix of subroots and a boolean status.

◆ remove_lakes()

void hmap::DrainageBasinCellBased::remove_lakes ( const Mat< glm::ivec2 > &  subroot)

Remove lakes by draining local depressions.

Parameters
subrootMatrix representing subroots.

◆ get_main_channels()

std::vector< std::vector< glm::ivec2 > > hmap::DrainageBasinCellBased::get_main_channels ( ) const

Get the main channel paths of the flow network.

Returns
A vector of main channels, each represented as a vector of 2D grid coordinates.

◆ compute_response_times()

Array hmap::DrainageBasinCellBased::compute_response_times ( const Array area_acc,
const Array erodibility,
float  m_exp 
) const

Compute response times of the basin cells.

Parameters
area_accAccumulated area array.
erodibilityErodibility coefficient array.
m_expErodibility exponent.
Returns
An Array of response times.

◆ update_elevations()

float hmap::DrainageBasinCellBased::update_elevations ( const Array response_times,
float  uplift_rate,
const Array max_slope 
)

Update elevations based on response times and uplift.

Parameters
response_timesArray of cell response times.
uplift_rateRate of tectonic uplift.
max_slopeMaximum allowed slope array.
Returns
The maximum change in elevation.

◆ accumulate_area_by_outlet()

void hmap::DrainageBasinCellBased::accumulate_area_by_outlet ( Array acc) const

Accumulate contributing area down the network by outlet.

Parameters
accOutput accumulated area array.

◆ flow_breach()

void hmap::DrainageBasinCellBased::flow_breach ( )

Perform flow breaching to resolve depressions.

Member Data Documentation

◆ z

Array hmap::DrainageBasinCellBased::z

The heightmap array.

◆ outlets_mask

Mat<int> hmap::DrainageBasinCellBased::outlets_mask

Mask indicating outlet cells.

◆ receivers

Mat<glm::ivec2> hmap::DrainageBasinCellBased::receivers

Grid of receiver coordinates.

◆ children

Mat<std::vector<glm::ivec2> > hmap::DrainageBasinCellBased::children

Grid of children coordinates.

◆ roots

Mat<glm::ivec2> hmap::DrainageBasinCellBased::roots

Grid of basin root.

◆ traversals

std::unordered_map<glm::ivec2, std::vector<glm::ivec2>, IVec2Hash> hmap::DrainageBasinCellBased::traversals

◆ null_cell

const glm::ivec2 hmap::DrainageBasinCellBased::null_cell = glm::ivec2(-1, -1)

Constant representing an.


The documentation for this class was generated from the following files: