opendrive_lane.h 3.42 KB
Newer Older
1
2
3
4
#ifndef _OPENDRIVE_LANE_H
#define _OPENDRIVE_LANE_H

#ifdef _HAVE_XSD
5
#include "xml/OpenDRIVE_1.4H.hxx"
6
7
#endif

8
#include "opendrive_common.h"
9
#include "opendrive_road_node.h"
10
#include "opendrive_road_segment.h"
11
#include "opendrive_lane.h"
12
13
14
15

class COpendriveLane
{
  friend class COpendriveRoadSegment;
16
17
  friend class COpendriveRoadNode;
  friend class COpendriveRoad;
18
19
  private:
    std::vector<COpendriveRoadNode *> nodes;
20
21
    std::vector<COpendriveLane *> next;
    std::vector<COpendriveLane *> prev;
22
23
24
25
    COpendriveLane *left_lane;
    opendrive_mark_t left_mark;
    COpendriveLane *right_lane;
    opendrive_mark_t right_mark;
26
27
    COpendriveRoadSegment *segment;
    double scale_factor;
28
    double resolution;
29
30
31
    double width;
    double speed;
    double offset;
32
    int id;
33
    unsigned int index;
34
  protected:
35
    COpendriveLane();
36
    COpendriveLane(const COpendriveLane &object);
37
    void load(const right::lane_type &lane_info,COpendriveRoadSegment *segment);
38
    void link_neightbour_lane(COpendriveLane *lane);
39
    void link_lane(COpendriveLane *lane,opendrive_mark_t mark,bool from_start,bool to_start);
40
41
    void add_next_lane(COpendriveLane *lane);
    void add_prev_lane(COpendriveLane *lane);
42
    void add_node(COpendriveRoadNode *node);
43
44
45
    bool has_node(COpendriveRoadNode *node);
    bool has_node(unsigned int index);
    void set_parent_segment(COpendriveRoadSegment *segment);
46
47
    void set_resolution(double res);
    void set_scale_factor(double scale);
48
49
    void set_width(double width);
    void set_speed(double speed);
50
    void set_offset(double offset);
51
52
53
54
55
56
57
58
59
    void set_id(int id);
    void set_index(unsigned int index);
    bool updated(lane_up_ref_t &refs);
    void update_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs);
    void clean_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs);
    void update_start_node(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,TOpendriveWorldPoint *start=NULL);
    COpendriveRoadNode *update_end_node(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,TOpendriveWorldPoint *end=NULL);
    COpendriveLane *get_sub_lane(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,COpendriveRoadNode **new_node,TOpendriveWorldPoint *start=NULL,TOpendriveWorldPoint *end=NULL);
    COpendriveLane *clone(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref);
60
  public:
61
62
63
    unsigned int get_num_nodes(void) const;
    const COpendriveRoadNode &get_node(unsigned int index) const;
    const COpendriveRoadSegment &get_segment(void) const;
64
65
66
67
    unsigned int get_num_next_lanes(void) const;
    const COpendriveLane &get_next_lane(unsigned int index) const;
    unsigned int get_num_prev_lanes(void) const;
    const COpendriveLane &get_prev_lane(unsigned int index) const;
68
69
70
    double get_width(void) const;
    double get_speed(void) const;
    double get_offset(void) const;
71
    unsigned int get_index(void) const;
72
    int get_id(void) const;
73
74
75
    TOpendriveWorldPoint get_start_point(void) const;
    TOpendriveWorldPoint get_end_point(void) const;
    double get_length(void) const;
76
77
    TOpendriveLocalPoint transform_to_local_point(TOpendriveTrackPoint &track);
    TOpendriveWorldPoint transform_to_world_point(TOpendriveTrackPoint &track);
78
    unsigned int get_closest_node(TOpendriveWorldPoint &point,double angle_tol=0.1);
79
80
81
82
83
    friend std::ostream& operator<<(std::ostream& out, COpendriveLane &lane);
    ~COpendriveLane();
};

#endif