Skip to content

Commit a749daa

Browse files
committed
Merge branch 'dev'
2 parents 87024be + deafa94 commit a749daa

89 files changed

Lines changed: 1274 additions & 434 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

HighMap/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION})
2121

2222
target_compile_definitions(
2323
${PROJECT_NAME} INTERFACE GLM_FORCE_SWIZZLE GLM_FORCE_INLINE
24-
GLM_ENABLE_EXPERIMENTAL _USE_MATH_DEFINES )
24+
GLM_ENABLE_EXPERIMENTAL _USE_MATH_DEFINES)
2525

2626
target_link_libraries(
2727
${PROJECT_NAME}

HighMap/include/highmap.hpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,15 @@
2727
#include "highmap/features.hpp"
2828
#include "highmap/filters.hpp"
2929
#include "highmap/functions.hpp"
30-
#include "highmap/geometry/cloud.hpp"
31-
#include "highmap/geometry/graph.hpp"
32-
#include "highmap/geometry/grids.hpp"
33-
#include "highmap/geometry/path.hpp"
34-
#include "highmap/geometry/point.hpp"
35-
#include "highmap/geometry/point_sampling.hpp"
30+
#include "highmap/geometry.hpp"
3631
#include "highmap/gradient.hpp"
37-
#include "highmap/hydrology/drainage_basin.hpp"
38-
#include "highmap/hydrology/hydrology.hpp"
39-
#include "highmap/interpolate1d.hpp"
40-
#include "highmap/interpolate2d.hpp"
41-
#include "highmap/interpolate_array.hpp"
42-
#include "highmap/interpolate_curve.hpp"
32+
#include "highmap/hydrology.hpp"
33+
#include "highmap/interpolate.hpp"
4334
#include "highmap/kernels.hpp"
4435
#include "highmap/local_metrics.hpp"
45-
#include "highmap/math/core.hpp"
36+
#include "highmap/math.hpp"
4637
#include "highmap/morphology.hpp"
47-
#include "highmap/multiscale/downscaling.hpp"
48-
#include "highmap/multiscale/pyramid.hpp"
49-
#include "highmap/multiscale/upscaling.hpp"
38+
#include "highmap/multiscale.hpp"
5039
#include "highmap/opencl/gpu_opencl.hpp"
5140
#include "highmap/openmp.hpp"
5241
#include "highmap/operator.hpp"
@@ -63,5 +52,4 @@
6352
#include "highmap/tensor.hpp"
6453
#include "highmap/terrain_tri_mesh.hpp"
6554
#include "highmap/transform.hpp"
66-
#include "highmap/virtual_array/virtual_array.hpp"
67-
#include "highmap/virtual_array/virtual_texture.hpp"
55+
#include "highmap/virtual_array.hpp"

HighMap/include/highmap/array.hpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Array
3535
* @brief The shape of the array {ni, nj}.
3636
*
3737
*/
38-
glm::ivec2 shape;
38+
glm::ivec2 shape = glm::ivec2(0, 0);
3939

4040
/**
4141
* @brief The underlying data storage, a vector of size shape.x * shape.y.
@@ -1037,6 +1037,8 @@ Array cv_mat_to_array(const cv::Mat &mat,
10371037
bool remap_values = true,
10381038
bool flip_j = false);
10391039

1040+
std::string get_opencv_build_information();
1041+
10401042
// ==========================================================================
10411043
// per cell operations wrapper(s)
10421044
// ==========================================================================
@@ -1063,27 +1065,4 @@ template <typename Fn> inline void for_each_cell(const Array &a, Fn &&fn)
10631065
fn(i, j, a(i, j));
10641066
}
10651067

1066-
/// Reduce all cells to a single value.
1067-
template <typename T, typename Fn, typename Reduce>
1068-
inline T reduce_cells(const Array &a, T init, Fn &&fn, Reduce &&reduce)
1069-
{
1070-
T acc = init;
1071-
1072-
for_each_cell(a,
1073-
[&](int i, int j, float v) { acc = reduce(acc, fn(i, j, v)); });
1074-
1075-
return acc;
1076-
}
1077-
1078-
/// Reduce all cells to a single value.
1079-
template <typename T, typename Fn, typename Reduce>
1080-
inline T reduce_cells(const Array &a, T init, Reduce &&reduce)
1081-
{
1082-
T acc = init;
1083-
1084-
for_each_cell(a, [&](int i, int j) { acc = reduce(acc, a(i, j)); });
1085-
1086-
return acc;
1087-
}
1088-
10891068
} // namespace hmap

HighMap/include/highmap/coord_frame.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
namespace hmap
2121
{
2222

23+
class VirtualArray; // forward decl.
24+
2325
class CoordFrame
2426
{
2527
public:

HighMap/include/highmap/erosion.hpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
#include "highmap/array.hpp"
88
#include "highmap/hydrology/hydrology.hpp"
9-
#include "highmap/interpolate2d.hpp"
9+
#include "highmap/interpolate/interpolate2d.hpp"
10+
#include "highmap/math/profiles.hpp"
1011
#include "highmap/terrain_tri_mesh.hpp"
1112

1213
// neighbor pattern search based on Moore pattern and define diagonal
@@ -27,32 +28,6 @@
2728
namespace hmap
2829
{
2930

30-
/**
31-
* @brief Procedural erosion angular profile type.
32-
*/
33-
enum ErosionProfile : int
34-
{
35-
EP_COSINE,
36-
EP_COSINE_BULK,
37-
EP_COSINE_PEAK,
38-
EP_PARABOL,
39-
EP_SAW_SHARP,
40-
EP_SAW_SMOOTH,
41-
EP_SHARP_VALLEYS,
42-
EP_SQRT,
43-
EP_TRIANGLE_GRENIER,
44-
EP_TRIANGLE_SHARP,
45-
EP_TRIANGLE_SMOOTH,
46-
};
47-
48-
std::function<float(float)> get_erosion_profile_function(
49-
const ErosionProfile &erosion_profile,
50-
float delta,
51-
float &profile_avg);
52-
53-
std::vector<hmap::ErosionProfile> check_erosion_profile_function(
54-
float delta = 0.01f);
55-
5631
/**
5732
* @brief Simulates terrain diffusion due to coastal erosion.
5833
*

HighMap/include/highmap/filters.hpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ Array bulkify(const Array &z,
7272
glm::vec2 center = {0.5f, 0.5f},
7373
glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
7474

75+
/**
76+
* @brief Reduce quantization artifacts using dithering and smoothing.
77+
*
78+
* Adds white noise dithering to the input array and applies iterative Laplacian
79+
* filtering to smooth quantization steps.
80+
*
81+
* @param array Input quantized array.
82+
* @param seed Random seed used for dithering noise generation.
83+
* @param dither_amplitude Amplitude of the added white noise.
84+
* @param filtering_iterations Number of Laplacian smoothing iterations.
85+
* @return Dequantized and smoothed array.
86+
*
87+
* **Example**
88+
* @include ex_dequantize.cpp
89+
*
90+
* **Result**
91+
* @image html ex_dequantize.png
92+
*/
93+
Array dequantize(const Array &array,
94+
std::uint32_t seed,
95+
float dither_amplitude = 0.01f,
96+
int filtering_iterations = 1);
97+
7598
/**
7699
* @brief Apply histogram equalization to the array values.
77100
*
@@ -889,6 +912,42 @@ void normal_displacement(Array &array,
889912
void plateau(Array &array, const Array *p_mask, int ir, float factor);
890913

891914
void plateau(Array &array, int ir, float factor); ///< @overload
915+
916+
/**
917+
* @brief Quantize array values into discrete levels.
918+
*
919+
* Values are clamped to the range [vmin, vmax] and remapped to `nlevels`
920+
* uniformly distributed discrete values.
921+
*
922+
* @param array Input array.
923+
* @param nlevels Number of quantization levels.
924+
* @param vmin Minimum clamp value.
925+
* @param vmax Maximum clamp value.
926+
* @return Quantized array.
927+
*
928+
* **Example**
929+
* @include ex_dequantize.cpp
930+
*
931+
* **Result**
932+
* @image html ex_dequantize.png
933+
*/
934+
Array quantize(const Array &array, int nlevels, float vmin, float vmax);
935+
936+
/**
937+
* @brief Quantize array values using the array min/max range.
938+
*
939+
* @param array Input array.
940+
* @param nlevels Number of quantization levels.
941+
* @return Quantized array.
942+
*
943+
* **Example**
944+
* @include ex_dequantize.cpp
945+
*
946+
* **Result**
947+
* @image html ex_dequantize.png
948+
*/
949+
Array quantize(const Array &array, int nlevels);
950+
892951
/**
893952
* @brief Transform heightmap to give a "billow" like appearance.
894953
*
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
5+
/**
6+
* @file geometry.hpp
7+
* @author Otto Link (otto.link.bv@gmail.com)
8+
* @copyright Copyright (c) 2023
9+
*/
10+
#pragma once
11+
12+
#include "highmap/geometry/cloud.hpp"
13+
#include "highmap/geometry/graph.hpp"
14+
#include "highmap/geometry/grids.hpp"
15+
#include "highmap/geometry/kd_tree.hpp"
16+
#include "highmap/geometry/path.hpp"
17+
#include "highmap/geometry/point.hpp"
18+
#include "highmap/geometry/point_sampling.hpp"

HighMap/include/highmap/geometry/cloud.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "highmap/array.hpp"
3232
#include "highmap/geometry/point.hpp"
3333
#include "highmap/geometry/point_sampling.hpp"
34-
#include "highmap/interpolate2d.hpp"
34+
#include "highmap/interpolate/interpolate2d.hpp"
3535

3636
namespace hmap
3737
{

HighMap/include/highmap/geometry/path.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#pragma once
2626
#include "highmap/boundary.hpp"
2727
#include "highmap/geometry/cloud.hpp"
28-
#include "highmap/interpolate1d.hpp"
28+
#include "highmap/interpolate/interpolate1d.hpp"
2929

3030
namespace hmap
3131
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
5+
/**
6+
* @file hydrology.hpp
7+
* @author Otto Link (otto.link.bv@gmail.com)
8+
* @copyright Copyright (c) 2023
9+
*/
10+
#pragma once
11+
12+
#include "highmap/hydrology/drainage_basin.hpp"
13+
#include "highmap/hydrology/drainage_basin_cell_based.hpp"
14+
#include "highmap/hydrology/hydrology.hpp"

0 commit comments

Comments
 (0)