scenario_simulator_v2 C++ API
grid_traversal.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
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 SIMPLE_SENSOR_SIMULATOR__SENSOR_SIMULATION__OCCUPANCY_GRID__GRID_TRAVERSAL_HPP_
16 #define SIMPLE_SENSOR_SIMULATOR__SENSOR_SIMULATION__OCCUPANCY_GRID__GRID_TRAVERSAL_HPP_
17 
18 #include <cmath>
19 #include <cstdint>
20 #include <utility>
22 {
24 {
25  using Index = std::pair<int32_t, int32_t>;
26 
27  struct Sentinel
28  {
29  };
30 
31  class Iterator
32  {
33  public:
34  Iterator(const GridTraversal * parent, double tx, double ty, int32_t x, int32_t y);
35 
36  auto operator*() -> Index;
37  auto operator++() -> Iterator &;
38  auto operator!=(const Sentinel &) -> bool;
39 
40  private:
41  const GridTraversal * parent_;
42 
43  double tx_, ty_;
44  int32_t x_, y_;
45  };
46 
47 public:
48  GridTraversal(double start_x, double start_y, double end_x, double end_y);
49 
50  auto begin() const -> Iterator;
51  auto end() const -> Sentinel;
52 
53 private:
54  double start_x_, start_y_;
55  double vx_, vy_;
56 
57  int32_t step_x_, step_y_;
58  double tdx_, tdy_;
59 };
60 
61 } // namespace simple_sensor_simulator
62 
63 #endif // SIMPLE_SENSOR_SIMULATOR__SENSOR_SIMULATION__OCCUPANCY_GRID__GRID_TRAVERSAL_HPP_
Definition: grid_traversal.hpp:24
auto begin() const -> Iterator
Definition: grid_traversal.cpp:34
GridTraversal(double start_x, double start_y, double end_x, double end_y)
Definition: grid_traversal.cpp:22
auto end() const -> Sentinel
Definition: grid_traversal.cpp:43
auto operator*(const T &a, const U &b)
Definition: operator.hpp:57
Definition: constants.hpp:19