00001
00002
00003
00004 #ifndef CAJUN_DRAW_RNDF_H
00005 #define CAJUN_DRAW_RNDF_H
00006
00007 #include <sstream>
00008 #include <GL/gl.h>
00009 #include "component_interface.H"
00010 #include "conf.H"
00011 #include "rndf.H"
00012 #include "proj_util.H"
00013 #include "cbviz_util.H"
00014
00015 #ifdef VR_JUGGLER
00016 #include <vrj/Draw/OGL/GlContextData.h>
00017 #endif
00018
00019 namespace cajun
00020 {
00021 class draw_rndf_t : public component_interface_t
00022 {
00023 public:
00024 draw_rndf_t (double cbviz_origin[3], conf_t &conf,
00025 world_state_t *ws_, rndf_t const *rndf_,
00026 char const *lane_markings_file_);
00027 virtual ~draw_rndf_t ();
00028 void toggle_display ();
00029 void update_data (double bot_pos_[3]);
00030 void display (double bot_pos_[3]);
00031 void init_data ();
00032 void load_textures ();
00033 void dump_waypoint (rndf_t::waypoint_t const &w_);
00034 void dump_boundary (char const *name_,
00035 rndf_t::lane_t::boundary_t boundary_);
00036 void dump_stop_line (rndf_t::waypoint_t const &w_);
00037 void dump_arrow (rndf_t::waypoint_t const &w_, int &type_,
00038 double &dx_, double &dy_, double &rot_);
00039 void dump_sign (rndf_t::waypoint_t const &w_, int &type_,
00040 double &dx_, double &dy_, double &rot_,
00041 double scale_, double height_);
00042 void dump_lane (rndf_t::lane_t const &l_);
00043 void dump_segment (rndf_t::segment_t const &s_);
00044 void dump_segment_filling (rndf_t::segment_t const &s_);
00045 void dump_perimeter (rndf_t::zone_t const &z_);
00046 void dump_spot (rndf_t::spot_t const &s_);
00047 void dump_zone (rndf_t::zone_t const &z_);
00048 void dump_intersection (rndf_t::intersection_t const &it_);
00049 private:
00050 class point_t
00051 {
00052 public:
00053 void operator=(rndf_t::waypoint_t const &wp_);
00054 double x;
00055 double y;
00056 };
00057
00058 struct stripe_t
00059 {
00060 point_t p1;
00061 point_t p2;
00062 };
00063
00064 class lane_id_t
00065 {
00066 public:
00067 bool operator<(const lane_id_t &lid_) const;
00068 bool operator==(const lane_id_t &lid_) const;
00069 unsigned m_seg_id;
00070 unsigned m_lane_id;
00071 };
00072
00073 class lane_marking_waypoint_t
00074 {
00075 public:
00076 bool operator<(const lane_marking_waypoint_t &l_) const;
00077 bool operator==(const lane_marking_waypoint_t &l_) const;
00078 bool valid (rndf_t const * rndf_);
00079 void reset ();
00080 unsigned m_segment;
00081 unsigned m_lane;
00082 unsigned m_waypoint;
00083 point_t m_delta;
00084 double m_rotation;
00085 int m_type;
00086 };
00087
00088 struct crosswalk_t
00089 {
00090 lane_marking_waypoint_t m_lm1;
00091 lane_marking_waypoint_t m_lm2;
00092 point_t m_transl;
00093 double m_rotation;
00094 };
00095
00096 class intersection_vertex_t
00097 {
00098 public:
00099 intersection_vertex_t ();
00100 intersection_vertex_t (rndf_t::waypoint_t const &wp_);
00101 bool operator<(const intersection_vertex_t &iv_) const;
00102 bool operator==(const intersection_vertex_t &iv_) const;
00103 void set (rndf_t::waypoint_t const &wp_);
00104 void set_orient (double orient_);
00105 rndf_t::waypoint_id_t& get_id ();
00106 bool valid ();
00107 double x ();
00108 double y ();
00109 double orient ();
00110 private:
00111 rndf_t::waypoint_id_t m_wpid;
00112 double m_x;
00113 double m_y;
00114 double m_orient;
00115 bool m_valid;
00116 };
00117
00118 void draw_park_lines (rndf_t::waypoint_t const &w1_,
00119 rndf_t::waypoint_t const &w2_,
00120 double width_);
00121 void draw_crosswalk (crosswalk_t const &cw_,
00122 double stroke_width_,
00123 double stroke_separation_);
00124 void load_lane_markings (char const *lane_markings_file_);
00125 bool parse_lane_marking (char *read_str, lane_marking_waypoint_t &lm_);
00126 void draw_double_yellow_lines (rndf_t::lane_t const &l_);
00127 void draw_single_white_lines (rndf_t::lane_t const &l_,
00128 rndf_t::lane_t::side_t side_);
00129 void draw_striped_white_lines (rndf_t::lane_t const &l_);
00130 void draw_straight_arrow (double lane_width, double thickness,
00131 int type);
00132 void draw_left_arrow (double lane_width,
00133 double thickness, int type);
00134 void draw_right_arrow (double lane_width_, double thickness_, int type_);
00135 void draw_stop_sign (double lane_width_, double scale_, double height_);
00136 void draw_yield_sign (double lane_width_, double scale_, double height_);
00137 void draw_curved_road_sign (double lane_width_, double scale_, double height_);
00138 void draw_bus_stop_sign (double lane_width_, double scale_, double height_);
00139 void draw_pole (double lane_width_, double scale_, double height_);
00140 bool is_arrow_type (int type_);
00141 bool is_sign_type (int type_);
00142 bool is_matching_lane_marking (rndf_t::lane_t const &l1_,
00143 rndf_t::lane_t const &l2_,
00144 rndf_t::lane_t::side_t side_wrt_l1_,
00145 bool same_dir_);
00146 bool is_same_direction (rndf_t::lane_t const &l1_,
00147 rndf_t::lane_t const &l2_);
00148 bool is_on_left_side (rndf_t::lane_t const &l1_,
00149 rndf_t::lane_t const &l2_);
00150 double trans_x (double x);
00151 double trans_y (double y);
00152 void set_glColor (chart_color_t color_);
00153 double wp_dist (rndf_t::waypoint_t const &w1_,
00154 rndf_t::waypoint_t const &w2_);
00155 double pt_dist (point_t const &p1_, point_t const &p2_);
00156 double orientation (point_t const &p1_, point_t const &p2_);
00157
00158 char m_lane_marker[20];
00159 rndf_t const *m_rndf;
00160 std::vector<unsigned> m_display_lists;
00161 #ifdef VR_JUGGLER
00162 vrj::GlContextData<GLuint> m_tmp_dl;
00163 #else
00164 unsigned m_tmp_dl;
00165 #endif
00166 unsigned m_points_per_dl;
00167 unsigned m_point_count;
00168
00169 double m_cbviz_origin[3];
00170 double m_ground_ref_height;
00171 std::vector<lane_marking_waypoint_t> m_lane_markings;
00172 std::vector<crosswalk_t> m_crosswalks;
00173 std::vector<lane_id_t> m_striped_lanes;
00174 std::vector<stripe_t> m_stripe_pts;
00175 bool m_display_checkpoint;
00176 bool m_display_exit;
00177 bool m_display_entry;
00178 bool m_display_waypoint;
00179 bool m_display_boundary;
00180 bool m_display_stop;
00181 bool m_display_stop_line;
00182 double m_stop_line_thickness;
00183 double m_dist_to_stop_line;
00184 bool m_display_lane;
00185 bool m_display_lane_number;
00186 bool m_display_segment;
00187 bool m_display_segment_filling;
00188 bool m_display_intersection_filling;
00189 bool m_display_perimeter;
00190 bool m_display_spot;
00191 bool m_display_zone;
00192 bool m_display_arrow;
00193 double m_dist_to_arrow;
00194 bool m_display_sign;
00195 bool m_use_old_lane_boundary_drawing;
00196 bool m_fill_between_lanes;
00197 double m_fill_dist_tolerance;
00198 bool m_print_lm_load_info;
00199 double m_sign_thickness;
00200 double m_sign_step_val;
00201
00202 double m_waypoint_number_height;
00203 double m_waypoint_height;
00204 double m_waypoint_radius;
00205 double m_entryexit_line_height;
00206 chart_color_t m_checkpoint_color;
00207 chart_color_t m_checkpoint_text_color;
00208 chart_color_t m_stoppoint_color;
00209 chart_color_t m_exitpoint_color;
00210 chart_color_t m_entrypoint_color;
00211 chart_color_t m_waypoint_color;
00212 chart_color_t m_waypoint_text_color;
00213
00214 enum { TEX_STOP_SIGN, TEX_YIELD_SIGN, TEX_CURVED_ROAD_SIGN,
00215 TEX_BUS_STOP_SIGN, TEX_LAST_ITEM };
00216
00217 struct texture_t
00218 {
00219 unsigned char *image_data;
00220 unsigned width;
00221 unsigned height;
00222 };
00223
00224 std::string m_textures_name[TEX_LAST_ITEM];
00225 texture_t m_textures_info[TEX_LAST_ITEM];
00226
00227 #ifdef VR_JUGGLER
00228 vrj::GlContextData<GLuint> m_textures[TEX_LAST_ITEM];
00229 #else
00230 GLuint m_textures[TEX_LAST_ITEM];
00231 #endif
00232
00233
00234
00235 enum {LEFT_RECT_ARROW, LEFT_CURVED_ARROW,
00236 STRAIGHT_RECT_ARROW,
00237 RIGHT_RECT_ARROW, RIGHT_CURVED_ARROW,
00238 LEFT_BOUNDARY_OFF, RIGHT_BOUNDARY_OFF,
00239 LEFT_BOUNDARY_HIGH, RIGHT_BOUNDARY_HIGH,
00240 STOP_SIGN, LEFT_YIELD_SIGN, RIGHT_YIELD_SIGN,
00241 CURVED_ROAD_SIGN, BUS_STOP_SIGN, POLE,
00242 CROSSWALK
00243 };
00244 };
00245 }
00246 #endif