Template Class SparseValueGrid

Inheritance Relationships

Base Type

Class Documentation

template<typename MapType, int NDim>
class SparseValueGrid : public beluga::BaseRegularGrid<SparseValueGrid<MapType, NDim>, NDim>

Generic N dimensional sparse value regular grid.

Template Parameters:
  • MapType – Associative container representing a mapping from a Eigen::Vector<int, NDim> to a value of type MapType::mapped_type. It should implement a subset of standard library’s associative containers public API. In particular, given ‘m’ a possibly const instance of MapType:

    • MapType::key_type must be Eigen::Vector<int, NDim>.

    • MapType::mapped_type should be the value type of the associative container entries.

    • ’m.at(const Eigen::Vector<int, NDim>& cell_index) const’ should return a const reference to ‘MapType::value_type’ representing the value at that index, or throw ‘std::out_of_range’ if it doesn’t exist.

    • ’m.find(const Eigen::Vector<int, NDim>&)’ should follow the same API as std::map.

  • NDim – Dimension of the grid.

Public Types

using map_type = MapType

Underlying associative container.

using mapped_type = typename map_type::mapped_type

Value type of the key-value pairs stored in the data.

using key_type = typename map_type::key_type

Key type for the key-value pairs.

Public Functions

SparseValueGrid() = default

Construct without data and with a 1 cell/meter resolution.

inline explicit SparseValueGrid(map_type data, double resolution = 1.)

Constructs the grid.

Parameters:
  • data – Grid data.

  • resolution – Grid resolution.

inline double resolution() const

Gets grid resolution.

inline std::size_t size() const

Gets grid size (ie. number of grid cells).

inline const map_type &data() const

Gets grid data.

inline std::optional<mapped_type> data_at(const Eigen::Vector<int, NDim> &cell_index) const

Gets grid data at cell_index or std::nullopt if it’s not present.

inline std::optional<mapped_type> data_near(const Eigen::Vector<double, NDim> &coordinates) const

Gets grid data at real coordinates ‘coordinates’ or std::nullopt if it’s not present.