opendrive_road_segment.h 3.86 KB
Newer Older
1
2
3
4
#ifndef _OPENDRIVE_ROAD_SEGMENT_H
#define _OPENDRIVE_ROAD_SEGMENT_H

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

8
#include "opendrive_common.h"
9
10
11
#include "opendrive_lane.h"
#include "opendrive_signal.h"
#include "opendrive_object.h"
12
#include "opendrive_road.h"
13
#include "opendrive_road_node.h"
14

15
16
17
class COpendriveRoadSegment
{
  friend class COpendriveRoad;
18
19
  friend class COpendriveRoadNode;
  friend class COpendriveLane;
20
21
  private:
    std::map<int,COpendriveLane *> lanes;
22
    std::vector<COpendriveRoadNode *> nodes;
23
    COpendriveRoad *parent_road;
24
25
26
    double resolution;
    double scale_factor;
    double min_road_length;
27
28
    int num_right_lanes;
    int num_left_lanes;
29
30
    std::vector<COpendriveSignal *> signals;
    std::vector<COpendriveObject *> objects;
31
    std::vector<COpendriveRoadSegment *> connecting;
32
33
    std::string name;
    unsigned int id;
34
    opendrive_mark_t center_mark;
35
  protected:
36
    COpendriveRoadSegment();
37
    COpendriveRoadSegment(const COpendriveRoadSegment &object);
38
    void load(OpenDRIVE::road_type &road_info);
39
    void free(void);
40
41
    void set_resolution(double res);
    void set_scale_factor(double scale);
42
    void set_min_road_length(double length);
43
    void set_parent_road(COpendriveRoad *parent);
44
45
46
47
    void set_name(std::string &name);
    void set_id(unsigned int id);
    void set_center_mark(opendrive_mark_t mark);
    bool updated(segment_up_ref_t &segment_refs);
48
    COpendriveRoadSegment *get_original_segment(segment_up_ref_t &segment_refs);
49
50
    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);
51
    void add_lanes(lanes::laneSection_type &lane_section);
Sergi Hernandez's avatar
Sergi Hernandez committed
52
    void add_lane(const ::lane &lane_info);
53
    void remove_lane(COpendriveLane *lane);
54
    void add_nodes(OpenDRIVE::road_type &road_info);
Sergi Hernandez's avatar
Sergi Hernandez committed
55
    void add_node(const planView::geometry_type &geom_info,COpendriveLane *lane);
56
    void add_empty_node(TOpendriveWorldPose &pose,COpendriveLane *lane);
57
58
59
    void remove_node(COpendriveRoadNode *node);
    bool has_node(COpendriveRoadNode *node);
    int get_node_side(COpendriveRoadNode *node);
60
    void link_neightbour_lanes(lanes::laneSection_type &lane_section);
Sergi Hernandez's avatar
Sergi Hernandez committed
61
62
63
    void link_neightbour_lanes(void);
    void link_segment(COpendriveRoadSegment *segment);
    void link_segment(COpendriveRoadSegment *segment,int from,bool from_start, int to,bool to_start);
64
    bool connects_to(COpendriveRoadSegment *segment);
65
    bool connects_segments(COpendriveRoadSegment *segment1,COpendriveRoadSegment *segment2);
66
    COpendriveRoadSegment *get_sub_segment(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,int node_side,TOpendriveWorldPose *start=NULL,TOpendriveWorldPose *end=NULL);
67
    COpendriveRoadSegment *clone(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref);
68
  public:
69
70
71
72
73
    std::string get_name(void) const;
    unsigned int get_id(void) const;
    unsigned int get_num_right_lanes(void) const;
    unsigned int get_num_left_lanes(void) const;
    const COpendriveLane &get_lane(int index) const;
74
75
    unsigned int get_num_nodes(void) const;
    const COpendriveRoadNode &get_node(unsigned int index) const;
76
    const COpendriveRoad &get_parent_road(void) const;
77
78
    unsigned int get_num_signals(void) const;
    const COpendriveSignal &get_signal(unsigned int index) const;
79
    unsigned int get_num_objects(void) const;
80
    const COpendriveObject &get_object(unsigned int index) const;
81
82
    unsigned int get_num_connecting(void) const;
    const COpendriveRoadSegment &get_connecting(unsigned int index) const;
83
84
    TOpendriveLocalPose transform_to_local_pose(const TOpendriveTrackPose &track);
    TOpendriveWorldPose transform_to_world_pose(const TOpendriveTrackPose &track);
85
    friend std::ostream& operator<<(std::ostream& out, COpendriveRoadSegment &segment);
86
87
88
89
    ~COpendriveRoadSegment();
};

#endif