1 #ifndef SLAM_CTOR_UTILS_DG_GRID_MAP_PATCHER_INCLUDED 2 #define SLAM_CTOR_UTILS_DG_GRID_MAP_PATCHER_INCLUDED 10 #include "../../core/maps/grid_map.h" 26 template<
typename MapType>
29 int w_zoom = 1,
int h_zoom = 1) {
33 template<
typename MapType>
35 int w_zoom = 1,
int h_zoom = 1) {
42 return Occupancy{ch ==
' ' ? 0.0 : 1.0, 1.0};
45 template<
typename MapType>
48 int w_zoom,
int h_zoom) {
49 assert(0 < w_zoom && 0 < h_zoom);
58 int w_scale,
int h_scale) {
63 std::string raw_map_row;
64 while (raster.good()) {
65 std::getline(raster, raw_map_row);
66 if (raw_map_row.size() == 0) {
70 for (
int row_i = 0; row_i < h_scale; ++row_i) {
72 for (
auto ch : raw_map_row) {
74 for (
int col_i = 0; col_i < w_scale; ++col_i) {
75 patches.emplace_back(world_coord,
occupancy);
82 static_cast< int>(raw_map_row.size()));
88 template<
typename MapType>
94 for (
auto &upd_req : patches) {
95 aoo.occupancy = upd_req.occupancy;
96 dst_map.update(upd_req.coord + offset, aoo);
GMPatches patches_by_text_raster(std::istream &raster, int w_scale, int h_scale)
GridMapPatch(const DiscretePoint2D &c, const Occupancy &occ)
void apply_patches(MapType &dst_map, const DiscretePoint2D &offset, const GMPatches &patches)
std::vector< GridMapPatch > GMPatches
void apply_text_raster(MapType &dst_map, std::istream &src_raster, const DiscretePoint2D &dst_offset, int w_zoom=1, int h_zoom=1)
void apply_text_raster(MapType &dst_map, std::istream &src_raster, int w_zoom=1, int h_zoom=1)
void apply_text_raster(MapType &dst_map, std::istream &src_raster, bool autoalign, const DiscretePoint2D &dst_offset, int w_zoom, int h_zoom)
Occupancy char_to_occupancy(char ch)