opendrive_road_segment.h 3.68 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);
52
    void remove_lane(COpendriveLane *lane);
53
    void add_nodes(OpenDRIVE::road_type &road_info);
54
55
56
57
    void add_node(COpendriveRoadNode *node);
    void remove_node(COpendriveRoadNode *node);
    bool has_node(COpendriveRoadNode *node);
    int get_node_side(COpendriveRoadNode *node);
58
59
    void link_neightbour_lanes(lanes::laneSection_type &lane_section);
    void link_segment(COpendriveRoadSegment &segment);
60
    void link_segment(COpendriveRoadSegment &segment,int from,bool from_start, int to,bool to_start);
61
    bool connects_to(COpendriveRoadSegment *segment);
62
    bool connects_segments(COpendriveRoadSegment *segment1,COpendriveRoadSegment *segment2);
63
64
    COpendriveRoadSegment *get_sub_segment(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,int node_side,TOpendriveWorldPoint *start=NULL,TOpendriveWorldPoint *end=NULL);
    COpendriveRoadSegment *clone(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref);
65
  public:
66
67
68
69
70
    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;
71
72
    unsigned int get_num_nodes(void) const;
    const COpendriveRoadNode &get_node(unsigned int index) const;
73
    const COpendriveRoad &get_parent_road(void) const;
74
75
    unsigned int get_num_signals(void) const;
    const COpendriveSignal &get_signal(unsigned int index) const;
76
    unsigned int get_num_objects(void) const;
77
    const COpendriveObject &get_object(unsigned int index) const;
78
79
    unsigned int get_num_connecting(void) const;
    const COpendriveRoadSegment &get_connecting(unsigned int index) const;
80
81
    TOpendriveLocalPoint transform_to_local_point(const TOpendriveTrackPoint &track);
    TOpendriveWorldPoint transform_to_world_point(const TOpendriveTrackPoint &track);
82
    friend std::ostream& operator<<(std::ostream& out, COpendriveRoadSegment &segment);
83
84
85
86
    ~COpendriveRoadSegment();
};

#endif