00001
00002
00003
00004 #ifndef CAJUN_BOUNDARY_MARKER_H
00005 #define CAJUN_BOUNDARY_MARKER_H
00006
00007
00008 #include "map_grid.H"
00009 #include "rect_filler.H"
00010 #include <math.h>
00011
00012 #include "rndf.H"
00013
00014
00015 #include <vector>
00016
00017
00018 namespace cajun
00019 {
00020
00021
00022
00023
00024
00025 class zone_marker_t
00026 {
00027 public:
00028 zone_marker_t (map_grid_t *map_grid_,
00029 double cell_size_, rndf_t const *rndf_,
00030 unsigned zone_id_);
00031
00032 struct cost_t
00033 {
00034 float dist;
00035 float cost;
00036 };
00037
00038 void mark ();
00039 void mark_boundary ();
00040 void mark_all_parking_spots ();
00041 void mark_parking_spot (unsigned spot_id_);
00042
00043 private:
00044 class filler_t
00045 {
00046 public:
00047 filler_t (map_grid_t *map_grid_) :
00048 m_map_grid (map_grid_), m_cost (FLT_MAX) {}
00049 void set_cost (float cost_) { m_cost = cost_; }
00050
00051 void fill (int x_, int y_, unsigned w_)
00052 {
00053 map_grid_t::iterator_t iter =
00054 m_map_grid->find (x_, y_);
00055
00056 while (w_--)
00057 {
00058 iter->boundary = m_cost;
00059 iter.neighbor (1, 0);
00060 }
00061 }
00062
00063 protected:
00064 map_grid_t * const m_map_grid;
00065
00066 float m_cost;
00067 };
00068
00069 double m_cell_size;
00070
00071 filler_t m_filler;
00072 rect_filler_t m_rect_filler;
00073
00074 rndf_t const *m_rndf;
00075 unsigned m_zone_id;
00076
00077 void fill (double x0_, double y0_,
00078 double x1_, double y1_, double size_)
00079 {
00080 double orient = atan2 (y1_ - y0_, x1_ - x0_);
00081 double dx = size_ * cos (orient);
00082 double dy = size_ * sin (orient);
00083
00084 x0_ -= dx;
00085 y0_ -= dy;
00086 x1_ += dx;
00087 y1_ += dy;
00088
00089 m_rect_filler.fill (m_filler,
00090 x0_ / m_cell_size, y0_ / m_cell_size,
00091 x1_ / m_cell_size, y1_ / m_cell_size,
00092 size_ / m_cell_size);
00093 }
00094 };
00095
00096
00097 };
00098
00099
00100 #endif