|
HighMap library (C++)
|
Triangle mesh representation of a terrain surface. More...
#include <terrain_tri_mesh.hpp>
Classes | |
| struct | BoundingBox |
| Axis-aligned 2D bounding box. More... | |
| struct | Edge |
| Undirected edge between two vertices. More... | |
| struct | EdgeHash |
| Hash functor for Edge. More... | |
| struct | Neighbor |
| Neighbor vertex information. More... | |
| struct | NeighborData |
| Vertex adjacency lists. More... | |
| struct | ShortestPathResult |
| Result of a shortest-path computation. More... | |
| struct | Triangle |
| Triangle defined by three vertex indices. More... | |
Public Member Functions | |
| TerrainTriMesh ()=default | |
| Construct an empty mesh. | |
| TerrainTriMesh (const std::vector< glm::vec3 > &ref_points) | |
| Construct a mesh from 3D points. | |
| TerrainTriMesh (const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &z) | |
| Construct a mesh from coordinate arrays. | |
| void | triangulate_delaunay () |
| Build the Delaunay triangulation. | |
| void | compute_neighbors () |
| Compute vertex adjacency. | |
| void | compute_gradients () |
| Compute vertex gradients. | |
| void | relax_xy (float lambda=0.5f, int iterations=1, bool preserve_chull=true) |
| Relax vertex positions in the XY plane. | |
| void | relax_xyz (float lambda=0.5f, int iterations=1, bool preserve_chull=true) |
| Relax vertex positions in 3D. | |
| void | relax_xyz_taubin (float lambda=0.5f, float mu=-0.55f, int iterations=1, bool preserve_chull=true) |
| Apply Taubin smoothing. | |
| void | remap_z (float vmin=0.f, float vmax=1.f) |
| Remap elevation values. | |
| void | slope_limiter (float max_slope, int iterations=10, float sigma=0.1f) |
| Limit terrain slopes. | |
| void | slope_limiter (const std::vector< float > &max_slope, int iterations=10, float sigma=0.1f) |
| Limit terrain slopes with per-vertex thresholds. | |
| void | subdivise () |
| Subdivide mesh triangles. | |
| void | flow_breach (float epsilon, float uphill_tolerance=0.f) |
| Breach terrain depressions for flow routing. | |
| bool | barycentric (const glm::vec2 &p, size_t i0, size_t i1, size_t i2, float &w0, float &w1, float &w2) const |
| Compute barycentric coordinates. | |
| int | find_triangle (const glm::vec2 &p, int start_tri=0, bool linear_search=false) const |
| Find the triangle containing a point. | |
| int | neighbor_triangle (int tri_index, int edge_index) const |
| Return the neighboring triangle across an edge. | |
| float | interpolate_z_linear (const glm::vec2 &p, int &last_tri, float fill_value=0.f) const |
| Linearly interpolate elevation. | |
| float | interpolate_z_linear_gradient (const glm::vec2 &p, int &last_tri, float fill_value=0.f, float gradient_scaling=1.f) const |
| Gradient-enhanced linear interpolation. | |
| float | interpolate_z_nearest (const glm::vec2 &p) const |
| Nearest-neighbor interpolation. | |
| float | interpolate_z_nearest_approx (const glm::vec2 &p, int &last_tri, float fill_value=0.f) const |
| Approximate nearest-neighbor interpolation. | |
| BoundingBox | get_bbox () const |
| Return the mesh bounding box. | |
| glm::vec2 | get_range_z () const |
| Return the elevation range. | |
| glm::vec3 | get_reference_lengths () const |
| Return reference mesh dimensions. | |
| std::vector< float > | get_vertex_areas (bool normalized) const |
| Compute vertex areas. | |
| float | get_reference_area_xy () const |
| Return the projected mesh area. | |
| float | get_reference_area () const |
| Return the mesh surface area. | |
| size_t | size () const |
| Return the number of vertices. | |
| ShortestPathResult | compute_shortest_paths_to_hull (bool use_delta_z=false, float elevation_weight=1.f) const |
| Compute shortest paths to the convex hull. | |
| ShortestPathResult | compute_shortest_paths (size_t start, bool use_delta_z=false, float elevation_weight=1.f) const |
| Compute shortest paths from a source vertex. | |
| std::vector< size_t > | shortest_path (size_t start, size_t end, bool use_delta_z=false, float elevation_weight=1.f) const |
| Compute the shortest path between two vertices. | |
| std::vector< size_t > | path_to_hull (size_t start, const ShortestPathResult &result) const |
| Reconstruct a path to the convex hull. | |
| const std::vector< glm::vec3 > & | get_points () const |
| Return mesh vertices. | |
| std::vector< glm::vec3 > & | get_points () |
| Return mesh vertices. | |
| const std::vector< Triangle > & | get_triangles () const |
| Return mesh triangles. | |
| const std::vector< size_t > & | get_convex_hull () const |
| Return convex hull vertex indices. | |
| const NeighborData & | get_neighbors () const |
| Return vertex neighbors. | |
| bool | export_obj (const std::string &filepath) const |
| Export the mesh as an OBJ file. | |
| std::string | info_string () const |
| Return a mesh summary string. | |
| void | print_info () const |
| Print mesh information. | |
| Array | to_array (const glm::ivec2 &shape, const std::vector< float > &values={}, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f}) const |
| Rasterize the mesh into an array. | |
| void | to_csv (const std::string &fname) const |
| Export vertices to CSV. | |
Triangle mesh representation of a terrain surface.
Stores vertices, triangulation, connectivity, and provides geometry, interpolation, smoothing, and pathfinding utilities.
|
default |
Construct an empty mesh.
| hmap::TerrainTriMesh::TerrainTriMesh | ( | const std::vector< glm::vec3 > & | ref_points | ) |
Construct a mesh from 3D points.
| hmap::TerrainTriMesh::TerrainTriMesh | ( | const std::vector< float > & | x, |
| const std::vector< float > & | y, | ||
| const std::vector< float > & | z | ||
| ) |
Construct a mesh from coordinate arrays.
| void hmap::TerrainTriMesh::triangulate_delaunay | ( | ) |
Build the Delaunay triangulation.
| void hmap::TerrainTriMesh::compute_neighbors | ( | ) |
Compute vertex adjacency.
| void hmap::TerrainTriMesh::compute_gradients | ( | ) |
Compute vertex gradients.
| void hmap::TerrainTriMesh::relax_xy | ( | float | lambda = 0.5f, |
| int | iterations = 1, |
||
| bool | preserve_chull = true |
||
| ) |
Relax vertex positions in the XY plane.
| void hmap::TerrainTriMesh::relax_xyz | ( | float | lambda = 0.5f, |
| int | iterations = 1, |
||
| bool | preserve_chull = true |
||
| ) |
Relax vertex positions in 3D.
| void hmap::TerrainTriMesh::relax_xyz_taubin | ( | float | lambda = 0.5f, |
| float | mu = -0.55f, |
||
| int | iterations = 1, |
||
| bool | preserve_chull = true |
||
| ) |
Apply Taubin smoothing.
| void hmap::TerrainTriMesh::slope_limiter | ( | float | max_slope, |
| int | iterations = 10, |
||
| float | sigma = 0.1f |
||
| ) |
Limit terrain slopes.
| void hmap::TerrainTriMesh::slope_limiter | ( | const std::vector< float > & | max_slope, |
| int | iterations = 10, |
||
| float | sigma = 0.1f |
||
| ) |
Limit terrain slopes with per-vertex thresholds.
| void hmap::TerrainTriMesh::subdivise | ( | ) |
Subdivide mesh triangles.
| void hmap::TerrainTriMesh::flow_breach | ( | float | epsilon, |
| float | uphill_tolerance = 0.f |
||
| ) |
Breach terrain depressions for flow routing.
| bool hmap::TerrainTriMesh::barycentric | ( | const glm::vec2 & | p, |
| size_t | i0, | ||
| size_t | i1, | ||
| size_t | i2, | ||
| float & | w0, | ||
| float & | w1, | ||
| float & | w2 | ||
| ) | const |
Compute barycentric coordinates.
| int hmap::TerrainTriMesh::find_triangle | ( | const glm::vec2 & | p, |
| int | start_tri = 0, |
||
| bool | linear_search = false |
||
| ) | const |
Find the triangle containing a point.
| int hmap::TerrainTriMesh::neighbor_triangle | ( | int | tri_index, |
| int | edge_index | ||
| ) | const |
Return the neighboring triangle across an edge.
| float hmap::TerrainTriMesh::interpolate_z_linear | ( | const glm::vec2 & | p, |
| int & | last_tri, | ||
| float | fill_value = 0.f |
||
| ) | const |
Linearly interpolate elevation.
| float hmap::TerrainTriMesh::interpolate_z_linear_gradient | ( | const glm::vec2 & | p, |
| int & | last_tri, | ||
| float | fill_value = 0.f, |
||
| float | gradient_scaling = 1.f |
||
| ) | const |
Gradient-enhanced linear interpolation.
| float hmap::TerrainTriMesh::interpolate_z_nearest | ( | const glm::vec2 & | p | ) | const |
Nearest-neighbor interpolation.
| float hmap::TerrainTriMesh::interpolate_z_nearest_approx | ( | const glm::vec2 & | p, |
| int & | last_tri, | ||
| float | fill_value = 0.f |
||
| ) | const |
Approximate nearest-neighbor interpolation.
| TerrainTriMesh::BoundingBox hmap::TerrainTriMesh::get_bbox | ( | ) | const |
Return the mesh bounding box.
| glm::vec2 hmap::TerrainTriMesh::get_range_z | ( | ) | const |
Return the elevation range.
| glm::vec3 hmap::TerrainTriMesh::get_reference_lengths | ( | ) | const |
Return reference mesh dimensions.
| std::vector< float > hmap::TerrainTriMesh::get_vertex_areas | ( | bool | normalized | ) | const |
Compute vertex areas.
| float hmap::TerrainTriMesh::get_reference_area_xy | ( | ) | const |
Return the projected mesh area.
| float hmap::TerrainTriMesh::get_reference_area | ( | ) | const |
Return the mesh surface area.
| size_t hmap::TerrainTriMesh::size | ( | ) | const |
Return the number of vertices.
| TerrainTriMesh::ShortestPathResult hmap::TerrainTriMesh::compute_shortest_paths_to_hull | ( | bool | use_delta_z = false, |
| float | elevation_weight = 1.f |
||
| ) | const |
Compute shortest paths to the convex hull.
| TerrainTriMesh::ShortestPathResult hmap::TerrainTriMesh::compute_shortest_paths | ( | size_t | start, |
| bool | use_delta_z = false, |
||
| float | elevation_weight = 1.f |
||
| ) | const |
Compute shortest paths from a source vertex.
| std::vector< size_t > hmap::TerrainTriMesh::shortest_path | ( | size_t | start, |
| size_t | end, | ||
| bool | use_delta_z = false, |
||
| float | elevation_weight = 1.f |
||
| ) | const |
Compute the shortest path between two vertices.
| std::vector< size_t > hmap::TerrainTriMesh::path_to_hull | ( | size_t | start, |
| const ShortestPathResult & | result | ||
| ) | const |
Reconstruct a path to the convex hull.
| const std::vector< glm::vec3 > & hmap::TerrainTriMesh::get_points | ( | ) | const |
Return mesh vertices.
| std::vector< glm::vec3 > & hmap::TerrainTriMesh::get_points | ( | ) |
Return mesh vertices.
| const std::vector< TerrainTriMesh::Triangle > & hmap::TerrainTriMesh::get_triangles | ( | ) | const |
Return mesh triangles.
| const std::vector< size_t > & hmap::TerrainTriMesh::get_convex_hull | ( | ) | const |
Return convex hull vertex indices.
| const TerrainTriMesh::NeighborData & hmap::TerrainTriMesh::get_neighbors | ( | ) | const |
Return vertex neighbors.
| bool hmap::TerrainTriMesh::export_obj | ( | const std::string & | filepath | ) | const |
Export the mesh as an OBJ file.
| std::string hmap::TerrainTriMesh::info_string | ( | ) | const |
Return a mesh summary string.
| void hmap::TerrainTriMesh::print_info | ( | ) | const |
Print mesh information.
| Array hmap::TerrainTriMesh::to_array | ( | const glm::ivec2 & | shape, |
| const std::vector< float > & | values = {}, |
||
| const glm::vec4 & | bbox = {0.f, 1.f, 0.f, 1.f} |
||
| ) | const |
Rasterize the mesh into an array.
| void hmap::TerrainTriMesh::to_csv | ( | const std::string & | fname | ) | const |
Export vertices to CSV.