iridescence
Loading...
Searching...
No Matches
elevation_map.hpp
Go to the documentation of this file.
1#ifndef GLK_ELEVATION_MAP_HPP
2#define GLK_ELEVATION_MAP_HPP
3
4#include <GL/gl3w.h>
5#include <glk/drawable.hpp>
7
8namespace glk {
9
14public:
21 ElevationMapBuilder(double resolution, const Eigen::Vector2i& size, const Eigen::Vector2f& origin);
22
25
29 template <typename Vector>
30 std::vector<std::uint64_t> calc_cell_indices(const std::vector<Vector>& cells) const;
31
37 template <typename Vector>
38 void set_elevation(const std::vector<Vector>& cells, int elevation_index, const std::vector<std::uint64_t>& cell_indices, bool average = false);
39
45 template <typename Vector>
46 void set_cmap(const std::vector<Vector>& cells, int cmap_index, const std::vector<std::uint64_t>& cell_indices, bool average = false);
47
51 template <int WindowSize = 3>
52 void filter_elevation_map(bool process_valid_cells = true);
53
55 template <int WindowSize = 3>
57
58public:
59 double resolution; // Resolution of the map
60 double inv_resolution; // Inverse of the resolution
61
62 Eigen::Vector2i size; // Size of the map in number of cells (width, height)
63 Eigen::Vector2f origin; // Top-left corner of the map in world coordinates
64
65 Eigen::Array<float, -1, -1, Eigen::RowMajor> count_map; // Count of points in each cell
66 Eigen::Array<float, -1, -1, Eigen::RowMajor> elevation_map; // Elevation values for each cell
67 Eigen::Array<float, -1, -1, Eigen::RowMajor> color_map; // Color values for each cell (optional)
68};
69
72public:
77
80
82 void draw(glk::GLSLShader& shader) const;
83
84private:
85 MeshRenderingOptions options; // Rendering options
86
87 double resolution; // Resolution of the map
88 Eigen::Vector2i size; // Size of the map in number of cells (width, height)
89 Eigen::Vector2f origin; // Top-left corner of the map in world coordinates
90
91 int num_indices_faces; // Number of indices for faces
92 int num_indices_edges; // Number of indices for edges
93
94 GLuint vao; // Vertex Array Object
95 GLuint vbo; // Vertex Buffer Object
96 GLuint cbo; // Color Buffer Object
97 GLuint ebo_faces; // Element Buffer Object for faces
98 GLuint ebo_edges; // Element Buffer Object for edges
99};
100
101} // namespace glk
102
103#endif
Definition drawable.hpp:12
~ElevationMap()
Destructor.
void draw(glk::GLSLShader &shader) const
Draw the elevation map.
ElevationMap(const ElevationMapBuilder &builder, const MeshRenderingOptions &options=MeshRenderingOptions())
Constructor.
GLSLShader is a wrapper for OpenGL shader programs.
Definition glsl_shader.hpp:49
Definition async_buffer_copy.hpp:6
Builder for an elevation map.
Definition elevation_map.hpp:13
double resolution
Definition elevation_map.hpp:59
ElevationMapBuilder(double resolution, const Eigen::Vector2i &size, const Eigen::Vector2f &origin)
Constructor.
double inv_resolution
Definition elevation_map.hpp:60
void set_cmap(const std::vector< Vector > &cells, int cmap_index, const std::vector< std::uint64_t > &cell_indices, bool average=false)
Set the color values for the given cells in the elevation map.
std::vector< std::uint64_t > calc_cell_indices(const std::vector< Vector > &cells) const
Calculate the cell indices for a given set of cells.
void calc_cmap_gradient()
Replace the color map with its gradient magnitude.
Eigen::Array< float, -1, -1, Eigen::RowMajor > color_map
Definition elevation_map.hpp:67
Eigen::Vector2i size
Definition elevation_map.hpp:62
~ElevationMapBuilder()
Destructor.
Eigen::Vector2f origin
Definition elevation_map.hpp:63
Eigen::Array< float, -1, -1, Eigen::RowMajor > count_map
Definition elevation_map.hpp:65
Eigen::Array< float, -1, -1, Eigen::RowMajor > elevation_map
Definition elevation_map.hpp:66
void set_elevation(const std::vector< Vector > &cells, int elevation_index, const std::vector< std::uint64_t > &cell_indices, bool average=false)
Set the elevation values for the given cells in the elevation map.
void filter_elevation_map(bool process_valid_cells=true)
Apply local averaging filter to the elevation (and color) map.
Options for rendering meshes.
Definition mesh_rendering_options.hpp:12