1#ifndef TATOOINE_DETAIL_POINTSET_INVERSE_DISTANCE_WEIGHTING_SAMPLER_H
2#define TATOOINE_DETAIL_POINTSET_INVERSE_DISTANCE_WEIGHTING_SAMPLER_H
6template <
floating_po
int Real, std::
size_t NumDimensions,
typename T>
7 requires(flann_available())
19 typename pointset_t::template typed_vertex_property_type<T>;
27 Real
const radius = 1)
28 : m_pointset{ps}, m_property{property}, m_radius{radius} {}
46 auto [indices, squared_distances] =
48 if (indices.empty()) {
49 return parent_type::ood_tensor();
51 auto accumulated_prop_val = T{};
52 auto accumulated_weight = Real{};
54 auto index_it =
begin(indices);
55 auto squared_dist_it =
begin(squared_distances);
56 for (; index_it !=
end(indices); ++index_it, ++squared_dist_it) {
57 auto const& property_value = m_property[
vertex_handle{*index_it}];
58 if (*squared_dist_it == 0) {
59 return property_value;
61 auto const weight = 1 / *squared_dist_it;
62 accumulated_prop_val += property_value * weight;
63 accumulated_weight += weight;
65 return accumulated_prop_val / accumulated_weight;
Definition: inverse_distance_weighting_sampler.h:4
auto begin(Range &&range)
Definition: iterator_facade.h:318
auto end(Range &&range)
Definition: iterator_facade.h:322
Definition: inverse_distance_weighting_sampler.h:10
pointset_t const & m_pointset
Definition: inverse_distance_weighting_sampler.h:21
typename pointset_t::template typed_vertex_property_type< T > vertex_property_type
Definition: inverse_distance_weighting_sampler.h:19
inverse_distance_weighting_sampler(pointset_t const &ps, vertex_property_type const &property, Real const radius=1)
Definition: inverse_distance_weighting_sampler.h:25
inverse_distance_weighting_sampler(inverse_distance_weighting_sampler &&) noexcept=default
typename pointset_t::vertex_handle vertex_handle
Definition: inverse_distance_weighting_sampler.h:17
vertex_property_type const & m_property
Definition: inverse_distance_weighting_sampler.h:22
inverse_distance_weighting_sampler(inverse_distance_weighting_sampler const &)=default
Real real_type
Definition: field.h:17
T tensor_type
Definition: field.h:18
Definition: pointset.h:83
Definition: pointset.h:69
auto nearest_neighbors_radius_raw(pos_type const &x, Real const radius, flann::SearchParams const params={}) const -> std::pair< std::vector< int >, std::vector< Real > >
Definition: pointset.h:1088