1 #include <gtest/gtest.h> 3 #include "../directions.h" 4 #include "../../../src/core/maps/grid_rasterization.h" 25 auto half_side = side_len / 2;
26 auto rect =
Rectangle{-half_side, half_side,
29 return AreaIds{raw_ids.begin(), raw_ids.end()};
33 double bot_len,
double top_len,
34 double left_len,
double right_len) {
35 auto rect =
Rectangle{-bot_len + offset.
y, top_len + offset.
y,
36 -left_len + offset.
x, right_len + offset.
x};
38 return AreaIds{raw_ids.begin(), raw_ids.end()};
64 for (area_id.x = -1; area_id.x <= 1; ++area_id.x) {
65 for (area_id.y = -1; area_id.y <= 1; ++area_id.y) {
71 int expected_d_x_start = 0, expected_d_x_end = 0,
72 expected_d_y_start = 0, expected_d_y_end = 0;
76 expected_d_x_start = -1;
86 expected_d_y_start = -1;
96 for (
int d_x = expected_d_x_start; d_x <= expected_d_x_end; ++d_x) {
97 for (
int d_y = expected_d_y_start; d_y <= expected_d_y_end; ++d_y) {
98 expected.emplace(area_id.x + d_x, area_id.y + d_y);
103 auto actual =
area_to_ids(area_offset, bot, top, left, right);
105 ASSERT_EQ(expected, actual);
137 for (area_id.x = -1; area_id.x <= 1; ++area_id.x) {
138 for (area_id.y = -1; area_id.y <= 1; ++area_id.y) {
139 int d_x_limit = 1, d_y_limit = 1;
156 for (
int d_x = -1; d_x <= d_x_limit; ++d_x) {
157 for (
int d_y = -1; d_y <= d_y_limit; ++d_y) {
158 expected.emplace(area_id.x + d_x, area_id.y + d_y);
164 bot, top, left, right);
166 ASSERT_EQ(expected, actual);
177 if (c1.
x == c2.
x) {
return c1.
y < c2.
y; }
183 for (area_id.x = -1; area_id.x <= 1; ++area_id.x) {
184 for (area_id.y = -1; area_id.y <= 1; ++area_id.y) {
358 auto actual =
area_to_ids({0, 0}, Inf, Inf, Inf, Inf);
359 auto expected = std::set<RegularSquaresGrid::Coord>{
360 {-1, -1}, {-1, 0}, {0, -1}, {0, 0}, {1, -1}, {1, 0}};
361 ASSERT_EQ(expected, actual);
366 int main (
int argc,
char *argv[]) {
367 ::testing::InitGoogleTest(&argc, argv);
368 return RUN_ALL_TESTS();
AreaIds area_to_ids(const Point2D &offset, double bot_len, double top_len, double left_len, double right_len)
static constexpr double Dbl_Inf
AreaIds area_to_ids(const Point2D ¢er, double side_len)
Point2D cell_to_world(const Coord &cell) const
LVRect move_center(const Point2D &new_center) const
bool operator<(const RegularSquaresGrid::Coord &c1, const RegularSquaresGrid::Coord &c2)
static constexpr double Quat_Cell_Len
static constexpr double Grid_Scale
void test_area_alignement(const Directions &dirs)
void test_area_exceeding(const Directions &dirs)
int main(int argc, char *argv[])
static constexpr double Cell_Len
std::set< AreaId > AreaIds
TEST_F(RectangleGridRasterizationTest, emptyAreaInsideCell)
static constexpr double Half_Cell_Len
RectangleGridRasterizationTest()
RegularSquaresGrid::Coord AreaId