00001
00002
00003
00004
00005 #ifndef CAJUN_OBSTACLE_MARKER_H
00006 #define CAJUN_OBSTACLE_MARKER_H
00007
00008
00009 #include "map_grid.H"
00010 #include "world_state.H"
00011
00012 #include "rect_filler.H"
00013
00014 #include <vector>
00015
00016 namespace cajun
00017 {
00018
00019
00020 class conf_t;
00021
00022
00023 class obstacle_marker_t
00024 {
00025 public:
00026 obstacle_marker_t (world_state_t *ws_, map_grid_t *map_grid_,
00027 double cell_size_) :
00028 m_ws (ws_), m_map_grid (map_grid_),
00029 m_cell_size (cell_size_), m_filler (map_grid_) { init ();}
00030
00031
00032 void mark (double x_, double y_);
00033 void mark_line (double x1_, double y1_, double x2_, double y2_);
00034
00035 void unmark (double min_x_, double min_y_, double max_index_x_,
00036 double max_index_y_);
00037
00038 protected:
00039
00040 class filler_t
00041 {
00042 public:
00043 filler_t (map_grid_t *map_grid_) :
00044 m_map_grid (map_grid_), m_obstacle (0) {}
00045 void set_obstacle (bool is_obstacle_)
00046 { m_obstacle = is_obstacle_; }
00047
00048 void fill (int x_, int y_, unsigned w_)
00049 {
00050 map_grid_t::iterator_t iter =
00051 m_map_grid->find (x_, y_);
00052
00053 while (w_--)
00054 {
00055 if (m_obstacle)
00056 iter->obstacle = FLT_MAX;
00057 else
00058 iter->obstacle = 0;
00059
00060 iter.neighbor (1, 0);
00061 }
00062 }
00063
00064 protected:
00065 map_grid_t * const m_map_grid;
00066
00067 bool m_obstacle;
00068 };
00069
00070 rect_filler_t m_rect_filler;
00071
00072
00073
00074
00075 struct strip_t
00076 {
00077 int dx;
00078 int dy;
00079 std::vector<float> value;
00080 };
00081
00082 world_state_t *m_ws;
00083 map_grid_t *m_map_grid;
00084 double m_cell_size;
00085 filler_t m_filler;
00086
00087
00088 std::vector<strip_t> m_strip;
00089 bool init ();
00090 };
00091
00092
00093 };
00094
00095
00096 #endif