1 #include <gtest/gtest.h> 6 #include "../../core/mock_grid_cell.h" 8 #include "../../../src/utils/data_generation/map_primitives.h" 9 #include "../../../src/utils/data_generation/grid_map_patcher.h" 10 #include "../../../src/core/maps/plain_grid_map.h" 15 :
map{std::make_shared<MockGridCell>(),
26 int w_scale,
int h_scale) {
27 assert(fs.
top() <= 1 && fs.
bot() <= 1 && 0 <= fs.
left() && 0 <= fs.
right());
28 double left = offset.
x + fs.
left() * w_scale;
29 double top = offset.
y + (fs.
top() - 1) * h_scale + 1;
36 bool use_auto_offset =
false) {
37 auto offset = patch_offset;
38 if (use_auto_offset) {
41 mp.
height() * h_scale / 2};
44 offset, w_scale, h_scale);
48 std::vector<Rectangle> free_space = mp.
free_space();
49 std::vector<Rectangle> free_areas;
50 std::transform(free_space.begin(), free_space.end(),
51 std::back_inserter(free_areas),
58 const int Check_Left = offset.x - 1;
59 const int Check_Right = Check_Left + mp.
width() * w_scale + 1;
60 const int Check_Top = offset.y + 1;
61 const int Check_Bot = Check_Top - mp.
height() * h_scale - 1;
64 for (coord.
y = Check_Top; Check_Bot <= coord.
y; --coord.
y) {
65 for (coord.
x = Check_Left; coord.
x <= Check_Right; ++coord.
x) {
67 if (coord.
x == Check_Left || coord.
x == Check_Right ||
68 coord.
y == Check_Top || coord.
y == Check_Bot) {
75 for (
auto &fa : free_areas) {
76 is_free &= fa.contains(c_mid);
77 if (!is_free) {
break; }
79 double expected_cell_value = is_free ? 0.0 : 1.0;
80 ASSERT_EQ(expected_cell_value,
map[coord]);
201 int main (
int argc,
char *argv[]) {
202 ::testing::InitGoogleTest(&argc, argv);
203 return RUN_ALL_TESTS();
GridMapPatcher gm_patcher
static constexpr int Map_Height
virtual std::vector< Rectangle > free_space() const
Rectangle scale_and_move_free_space(const Rectangle &fs, const DiscretePoint2D &offset, int w_scale, int h_scale)
static constexpr int Map_Width
virtual int width() const
static constexpr double Map_Scale
UnboundedPlainGridMap map
void apply_text_raster(MapType &dst_map, std::istream &src_raster, const DiscretePoint2D &dst_offset, int w_zoom=1, int h_zoom=1)
static constexpr double Default_Occ_Prob
int main(int argc, char *argv[])
TEST_F(GridMapPatcherTest, patchCecumNoScaleNoOffset)
virtual int height() const
virtual double scale() const
void test_patching(const TextRasterMapPrimitive &mp, int w_scale, int h_scale, const DiscretePoint2D &patch_offset={0, 0}, bool use_auto_offset=false)