HighMap library (C++)
Loading...
Searching...
No Matches
hmap::KDTreeContext Struct Reference

Context wrapper for KD-tree operations. More...

#include <kd_tree.hpp>

Collaboration diagram for hmap::KDTreeContext:

Public Member Functions

 KDTreeContext (const std::vector< float > &x_, const std::vector< float > &y_)
 Construct the KD-tree context and build the index.
 
glm::vec2 compte_neighbor_distance_range (size_t k_neighbors) const
 Estimate the range of neighbor distances.
 
void neighbor_search (float x_query, float y_query, size_t k_neighbors, std::vector< size_t > &indices, std::vector< float > &distances) const
 Perform a k-nearest neighbor search.
 
std::vector< nanoflann::ResultItem< unsigned int, float > > radius_search (float x_query, float y_query, float radius) const
 Perform a radius-based neighbor search.
 

Public Attributes

const std::vector< float > & x
 
const std::vector< float > & y
 
NanoflannPointCloudAdaptor adaptor
 
KDTree index
 

Detailed Description

Context wrapper for KD-tree operations.

This class encapsulates:

  • input point data
  • nanoflann adaptor
  • KD-tree index

It provides convenient methods for nearest-neighbor and radius-based queries.

Note
The input vectors must remain valid for the lifetime of this object.

Constructor & Destructor Documentation

◆ KDTreeContext()

hmap::KDTreeContext::KDTreeContext ( const std::vector< float > &  x_,
const std::vector< float > &  y_ 
)

Construct the KD-tree context and build the index.

Parameters
x_Vector of x coordinates
y_Vector of y coordinates

Member Function Documentation

◆ compte_neighbor_distance_range()

glm::vec2 hmap::KDTreeContext::compte_neighbor_distance_range ( size_t  k_neighbors) const

Estimate the range of neighbor distances.

Computes the minimum and maximum distance to the k-th nearest neighbor across all points in the dataset.

Parameters
k_neighborsNumber of neighbors considered
Returns
vec2(min_distance, max_distance)

◆ neighbor_search()

void hmap::KDTreeContext::neighbor_search ( float  x_query,
float  y_query,
size_t  k_neighbors,
std::vector< size_t > &  indices,
std::vector< float > &  distances 
) const

Perform a k-nearest neighbor search.

Parameters
x_queryQuery x coordinate
y_queryQuery y coordinate
k_neighborsNumber of neighbors to retrieve
[out]indicesOutput indices of neighbors
[out]distancesOutput squared distances to neighbors

◆ radius_search()

std::vector< nanoflann::ResultItem< unsigned int, float > > hmap::KDTreeContext::radius_search ( float  x_query,
float  y_query,
float  radius 
) const

Perform a radius-based neighbor search.

Parameters
x_queryQuery x coordinate
y_queryQuery y coordinate
radiusSearch radius (Euclidean distance)
Returns
Vector of (index, squared distance) pairs
Note
Returned distances are squared distances.

Member Data Documentation

◆ x

const std::vector<float>& hmap::KDTreeContext::x

Reference to x coordinates

◆ y

const std::vector<float>& hmap::KDTreeContext::y

Reference to y coordinates

◆ adaptor

NanoflannPointCloudAdaptor hmap::KDTreeContext::adaptor

Nanoflann adaptor

◆ index

KDTree hmap::KDTreeContext::index

KD-tree index


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