Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/GNESegment.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GNESegment.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Nov 2024
17
///
18
// GNESegment used in Path Manager
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
// ===========================================================================
24
// class declaration
25
// ===========================================================================
26
27
class GNELane;
28
class GNEJunction;
29
class GNEPathElement;
30
class GNEPathManager;
31
32
// ===========================================================================
33
// class definitions
34
// ===========================================================================
35
36
class GNESegment {
37
38
public:
39
/// @brief constructor for lanes
40
GNESegment(GNEPathManager* pathManager, GNEPathElement* element, const GNELane* lane, std::vector<GNESegment*>& segments);
41
42
/// @brief constructor for junctions
43
GNESegment(GNEPathManager* pathManager, GNEPathElement* element, const GNEJunction* junction, std::vector<GNESegment*>& segments);
44
45
/// @brief destructor
46
~GNESegment();
47
48
/// @name functions related with segment contour
49
/// @{
50
/// @brief get contour associated with segment
51
GNEContour* getContour() const;
52
53
/// @brief get from contour associated with segment (only if this is the first path segment)
54
GNEContour* getFromContour() const;
55
56
/// @brief get to contour associated with segment (only if this is the last path segment)
57
GNEContour* getToContour() const;
58
59
/// @}
60
61
/// @brief functions related with the other paht segments
62
/// @{
63
/// @brief get next segment
64
GNESegment* getNextSegment() const;
65
66
/// @brief get previous segment
67
GNESegment* getPreviousSegment() const;
68
69
/// @brief check if segment is the first path's segment
70
bool isFirstSegment() const;
71
72
/// @brief check if segment is the last path's segment
73
bool isLastSegment() const;
74
75
/// @}
76
77
/// @name functions related with GNE elements associated with this segment
78
/// @{
79
/// @brief get path element
80
GNEPathElement* getPathElement() const;
81
82
/// @brief get lane associated with this segment
83
const GNELane* getLane() const;
84
85
/// @brief get previous lane
86
const GNELane* getPreviousLane() const;
87
88
/// @brief get next lane
89
const GNELane* getNextLane() const;
90
91
/// @brief get lane index
92
int getLaneIndex() const;
93
94
/// @brief get junction associated with this segment
95
const GNEJunction* getJunction() const;
96
97
/// @brief get lane index
98
int getJunctionIndex() const;
99
100
/// @}
101
102
/// @name functions related with labeling segments (used for certain elements as E2 multilane detectors)
103
/// @{
104
105
/// @brief check if segment is label segment
106
bool isLabelSegment() const;
107
108
/// @brief mark segment as middle segment
109
void markSegmentLabel();
110
111
/// @}
112
113
protected:
114
/// @brief pointer to path manager
115
GNEPathManager* myPathManager;
116
117
/// @brief path element associated with this segment
118
GNEPathElement* myPathElement;
119
120
/// @brief lane associated with this segment
121
const GNELane* myLane;
122
123
/// @brief junction associated with this segment
124
const GNEJunction* myJunction;
125
126
/// @brief lane index
127
int myLaneIndex = 0;
128
129
/// @brief junction index
130
int myJunctionIndex = 0;
131
132
/// @brief pointer to next segment
133
GNESegment* myNextSegment;
134
135
/// @brief pointer to previous segment
136
GNESegment* myPreviousSegment;
137
138
/// @brief flag for check if this segment is a label segment
139
bool myLabelSegment;
140
141
/// @brief contour associated with segment
142
GNEContour* myContour;
143
144
/// @brief from contour, used for moving elements (only in the first segment)
145
GNEContour* myFromContour;
146
147
/// @brief to contour, used for moving elements (only in the last segment)
148
GNEContour* myToContour;
149
150
private:
151
/// @brief default constructor
152
GNESegment();
153
154
/// @brief Invalidated copy constructor.
155
GNESegment(const GNESegment&) = delete;
156
157
/// @brief Invalidated assignment operator.
158
GNESegment& operator=(const GNESegment&) = delete;
159
};
160
161