value_grid.hpp
Go to the documentation of this file.
1 // Copyright 2023 Ekumen, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef BELUGA_SENSOR_DATA_VALUE_GRID_HPP
16 #define BELUGA_SENSOR_DATA_VALUE_GRID_HPP
17 
18 #include <cstdint>
19 #include <utility>
20 #include <vector>
21 
23 
29 namespace beluga {
30 
32 
35 template <typename T>
36 class ValueGrid2 : public BaseLinearGrid2<ValueGrid2<T>> {
37  public:
39 
44  explicit ValueGrid2(std::vector<T> data, std::size_t width, double resolution = 1.)
46  assert(data_.size() % width == 0);
47  }
48 
50  [[nodiscard]] std::size_t width() const { return width_; }
51 
53  [[nodiscard]] std::size_t height() const { return height_; }
54 
56  [[nodiscard]] double resolution() const { return resolution_; }
57 
59  [[nodiscard]] std::size_t size() const { return data_.size(); }
60 
62  [[nodiscard]] const std::vector<T>& data() const { return data_; }
63 
64  private:
65  std::vector<T> data_;
66  std::size_t width_;
67  std::size_t height_;
68  double resolution_;
69 };
70 
71 } // namespace beluga
72 
73 #endif
beluga::BaseLinearGrid2
Linear 2D grid base type.
Definition: linear_grid.hpp:64
beluga::ValueGrid2::data_
std::vector< T > data_
Definition: value_grid.hpp:65
linear_grid.hpp
Concepts and abstract implementations of linear (ie. contiguous storage) grids.
beluga::ValueGrid2::resolution
double resolution() const
Gets grid resolution.
Definition: value_grid.hpp:56
beluga::ValueGrid2::height
std::size_t height() const
Gets grid height.
Definition: value_grid.hpp:53
beluga::ValueGrid2::data
const std::vector< T > & data() const
Gets grid data.
Definition: value_grid.hpp:62
beluga::ValueGrid2::size
std::size_t size() const
Gets grid size (ie. number of grid cells).
Definition: value_grid.hpp:59
beluga::ValueGrid2::width
std::size_t width() const
Gets grid width.
Definition: value_grid.hpp:50
beluga::ValueGrid2::ValueGrid2
ValueGrid2(std::vector< T > data, std::size_t width, double resolution=1.)
Constructs the grid.
Definition: value_grid.hpp:44
beluga::ValueGrid2::width_
std::size_t width_
Definition: value_grid.hpp:66
std
Definition: circular_array.hpp:529
beluga::ValueGrid2::height_
std::size_t height_
Definition: value_grid.hpp:67
beluga::ValueGrid2
Generic 2D linear value grid.
Definition: value_grid.hpp:36
beluga
The main Beluga namespace.
Definition: 3d_embedding.hpp:21
beluga::ValueGrid2::resolution_
double resolution_
Definition: value_grid.hpp:68


beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53