opendrive_road.h 2.94 KB
Newer Older
1
2
3
4
#ifndef _OPENDRIVE_ROAD_H
#define _OPENDRIVE_ROAD_H

#ifdef _HAVE_XSD
Sergi Hernandez's avatar
Sergi Hernandez committed
5
#include "xml/OpenDRIVE_1.4H.hxx"
6
7
#endif

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

class COpendriveRoad
{
15
16
  friend class COpendriveRoadSegment;
  friend class COpendriveRoadNode;
17
  friend class COpendriveLane;
18
19
  private:
    std::vector<COpendriveRoadSegment *> segments;
20
    std::vector<COpendriveRoadNode *> nodes;
21
    std::vector<COpendriveLane *> lanes;
22
23
24
25
    double resolution;
    double scale_factor;
    double min_road_length;
  protected:
26
    COpendriveRoadSegment &operator[](std::string &key);
27
    void free(void);
28
    void link_segments(OpenDRIVE &open_drive);
29
    unsigned int add_node(COpendriveRoadNode *node);
30
31
32
    void remove_node(COpendriveRoadNode *node);
    unsigned int add_lane(COpendriveLane *lane);
    void remove_lane(COpendriveLane *lane);
33
    void complete_open_lanes(void);
34
    void add_segment(COpendriveRoadSegment *segment,std::vector<unsigned int> &old_path,std::vector<unsigned int> &new_path);
35
    bool has_segment(COpendriveRoadSegment *segment);
36
37
38
39
40
    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 prune(std::vector<unsigned int> &path_nodes);
    bool node_exists_at(TOpendriveWorldPoint &pose);
    COpendriveRoadNode* get_node_at(TOpendriveWorldPoint &pose);
41
42
43
44
  public:
    COpendriveRoad();
    COpendriveRoad(const COpendriveRoad& object);
    void load(const std::string &filename);
45
46
47
48
49
50
51
52
    void set_resolution(double res);
    void set_scale_factor(double scale);
    void set_min_road_length(double length);
    double get_resolution(void) const;
    double get_scale_factor(void) const;
    double get_min_road_length(void) const;
    unsigned int get_num_segments(void) const;
    const COpendriveRoadSegment& get_segment(unsigned int index) const;
53
54
    unsigned int get_num_nodes(void) const;
    const COpendriveRoadNode& get_node(unsigned int index) const;
55
    const COpendriveRoadSegment& operator[](std::size_t index);
56
57
58
    unsigned int get_closest_node(TOpendriveWorldPoint &point,double angle_tol=0.1);
    double get_closest_point(TOpendriveWorldPoint &point,TOpendriveWorldPoint &closest_point,double angle_tol=0.1);
    void get_closest_points(TOpendriveWorldPoint &point,std::vector<TOpendriveWorldPoint> &closest_points,std::vector<double> &closest_lengths,double dist_tol,double angle_tol=0.1);
59
    std::vector<unsigned int> get_sub_road(std::vector<unsigned int> &path_nodes,TOpendriveWorldPoint &start_point,TOpendriveWorldPoint &end_point,COpendriveRoad &new_road);
60
    void get_sub_road(TOpendriveWorldPoint &start_point,double length,COpendriveRoad &new_road);
61
62
63
64
65
66
    void operator=(const COpendriveRoad& object);
    friend std::ostream& operator<<(std::ostream& out, COpendriveRoad &road);
    ~COpendriveRoad();
};

#endif