HighMap library (C++)
Loading...
Searching...
No Matches
forest_seeding.hpp
Go to the documentation of this file.
1/* Copyright (c) 2025 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
9#pragma once
10
11#include <cstddef>
12#include <cstdint>
13#include <vector>
14
15#include <glm/glm.hpp>
16
17#include "highmap/array.hpp"
23
24namespace hmap
25{
26
32{
34 uint32_t seed = 0;
35 float exclusion_threshold = 0.f;
36 std::vector<Species> species = {};
37};
38
39// ============================================================================
40// Seeding Functions (Alphabetically Sorted)
41// ============================================================================
42
75Array build_tree_density(const Array &heightmap,
76 float min_elev = 0.0f,
77 float max_elev = 0.9f,
78 float elev_transition_width = 0.1f,
79 float min_talus = 0.003f,
80 float max_talus = 0.005f,
81 float angle = 30.0f,
82 float angle_width = 90.0f,
83 float weight_elev = 1.0f,
84 float weight_talus = 1.0f,
85 float weight_angle = 0.8f,
86 float weight_twi = 0.5f,
87 const Array &secondary_density = {},
88 float weight_secondary = 1.0f,
89 const Array &exclusion_mask = {},
90 float exclusion_threshold = 0.f);
91
108Forest seed_forest_clusters(size_t species_count,
109 size_t tree_count,
110 const Array &density,
111 const Array &exclusion,
112 float cluster_spread = 0.05f,
113 size_t points_per_cluster = 8,
114 const ForestSeedingOptions &options = {},
115 const UvTile &region = UvTile::unit(),
117
140Forest seed_forest_kmeans(size_t species_count,
141 size_t tree_count,
142 const Array &density,
143 const Array &exclusion,
144 float cluster_randomness = 0.0f,
145 size_t k_neighbors = 4,
146 const ForestSeedingOptions &options = {},
147 const UvTile &region = UvTile::unit(),
149
150} // namespace hmap
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:31
Container class representing a collection of Tree instances.
Definition forest.hpp:27
Abstract communicator interface providing MPI-style collective directives for single-source SPMD Arra...
Definition communicator_interface.hpp:60
static SingleArrayComm & instance()
Definition communicator.cpp:78
Definition opencv.hpp:20
Forest seed_forest_kmeans(size_t species_count, size_t tree_count, const Array &density, const Array &exclusion, float cluster_randomness=0.0f, size_t k_neighbors=4, const ForestSeedingOptions &options={}, const UvTile &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
Generates a multi-species forest distribution using 2D inverse transform sampling for positions and P...
Definition forest_seeding.cpp:320
Forest seed_forest_clusters(size_t species_count, size_t tree_count, const Array &density, const Array &exclusion, float cluster_spread=0.05f, size_t points_per_cluster=8, const ForestSeedingOptions &options={}, const UvTile &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
Generates a clustered forest distribution using inverse transform sampling for cluster centers and lo...
Definition forest_seeding.cpp:153
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:65
Array build_tree_density(const Array &heightmap, float min_elev=0.0f, float max_elev=0.9f, float elev_transition_width=0.1f, float min_talus=0.003f, float max_talus=0.005f, float angle=30.0f, float angle_width=90.0f, float weight_elev=1.0f, float weight_talus=1.0f, float weight_angle=0.8f, float weight_twi=0.5f, const Array &secondary_density={}, float weight_secondary=1.0f, const Array &exclusion_mask={}, float exclusion_threshold=0.f)
Computes an environmental suitability criteria map in [0, 1] representing tree probability density ba...
Definition forest_seeding.cpp:41
Axis-aligned 2D bounding box in world coordinates.
Definition bbox2d.hpp:25
Configuration parameters for forest seeding algorithms.
Definition forest_seeding.hpp:32
std::vector< Species > species
Optional Species definitions.
Definition forest_seeding.hpp:36
uint32_t seed
Random number generator seed.
Definition forest_seeding.hpp:34
BBox2D bbox
Bounding box {xmin, xmax, ymin, ymax}.
Definition forest_seeding.hpp:33
float exclusion_threshold
Threshold for exclusion map masking.
Definition forest_seeding.hpp:35
Describes an Array tile's position within the normalized [0, 1]^2 UV domain and global index grid.
Definition uv_tile.hpp:46
static const UvTile & unit()
Definition uv_tile.cpp:31
Normalized UV-domain tile descriptor for single-source SPMD Array algorithms and VirtualArray dispatc...