opendrive_road.h 2.93 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:
Sergi Hernandez's avatar
Sergi Hernandez committed
26
    COpendriveRoadSegment *get_segment_by_id(std::string &id);
27
    void free(void);
28
    void link_segments(OpenDRIVE &open_drive);
29
    unsigned int add_node(COpendriveRoadNode *node);
Sergi Hernandez's avatar
Sergi Hernandez committed
30
    bool remove_node(COpendriveRoadNode *node);
31
    unsigned int add_lane(COpendriveLane *lane);
Sergi Hernandez's avatar
Sergi Hernandez committed
32
    bool 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
    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);
39
40
    bool node_exists_at(TOpendriveWorldPose &pose);
    COpendriveRoadNode* get_node_at(TOpendriveWorldPose &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
59
60
    unsigned int get_closest_node(TOpendriveWorldPose &pose,double angle_tol=0.1);
    double get_closest_pose(TOpendriveWorldPose &pose,TOpendriveWorldPose &closest_pose,double angle_tol=0.1);
    void get_closest_poses(TOpendriveWorldPose &pose,std::vector<TOpendriveWorldPose> &closest_poses,std::vector<double> &closest_lengths,double dist_tol,double angle_tol=0.1);
    std::vector<unsigned int> get_sub_road(std::vector<unsigned int> &path_nodes,TOpendriveWorldPose &start_pose,TOpendriveWorldPose &end_pose,COpendriveRoad &new_road);
    void get_sub_road(TOpendriveWorldPose &start_pose,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