Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEPathManager.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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/****************************************************************************/
18// Manager for paths in netedit (routes, trips, flows...)
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <netbuild/NBEdge.h>
24#include <netbuild/NBVehicle.h>
29
30
31// ===========================================================================
32// class declaration
33// ===========================================================================
34
35class GNENet;
36class GNEEdge;
37class GNELane;
38class GNEJunction;
39class GNEAdditional;
40class GNEPathElement;
41class GNESegment;
42class GUIGlObject;
43
44// ===========================================================================
45// class definitions
46// ===========================================================================
47
49
51 friend class GNESegment;
52
53public:
54
57
58 public:
60 PathCalculator(const GNENet* net);
61
64
69
71 std::vector<GNEEdge*> calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges) const;
72
74 std::vector<GNEEdge*> calculateDijkstraPath(const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEEdge* toEdge) const;
75
77 std::vector<GNEEdge*> calculateDijkstraPath(const SUMOVehicleClass vClass, GNEEdge* fromEdge, GNEJunction* toJunction) const;
78
80 std::vector<GNEEdge*> calculateDijkstraPath(const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEEdge* toEdge) const;
81
83 std::vector<GNEEdge*> calculateDijkstraPath(const SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEJunction* toJunction) const;
84
86 void calculateReachability(const SUMOVehicleClass vClass, GNEEdge* originEdge);
87
89 bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge* from, const GNEEdge* to) const;
90
92 bool busStopConnected(const GNEAdditional* busStop, const GNEEdge* edge) const;
93
95 bool isPathCalculatorUpdated() const;
96
99
100 private:
102 const GNENet* myNet;
103
106
109
111 std::vector<GNEEdge*> optimizeJunctionPath(const std::vector<GNEEdge*>& edges) const;
112 };
113
115 class PathDraw {
116
117 public:
119 PathDraw();
120
122 ~PathDraw();
123
125 void clearPathDraw();
126
128 bool checkDrawPathGeometry(const GUIVisualizationSettings& s, const GNELane* lane, SumoXMLTag tag);
129
131 bool checkDrawPathGeometry(const GUIVisualizationSettings& s, const GNESegment* segment, SumoXMLTag tag);
132
133 private:
135 std::map<const GNELane*, std::set<SumoXMLTag> > myLaneDrawedElements;
136
138 std::map<const std::pair<const GNELane*, const GNELane*>, std::set<SumoXMLTag> > myLane2laneDrawedElements;
139 };
140
142 GNEPathManager(const GNENet* net);
143
146
149
151 const GNEPathElement* getPathElement(const GUIGlObject* GLObject) const;
152
154 const std::vector<GNESegment*>& getPathElementSegments(GNEPathElement* pathElement) const;
155
158
160 bool isPathValid(const GNEPathElement* pathElement) const;
161
163 const GNELane* getFirstLane(const GNEPathElement* pathElement) const;
164
166 void calculatePath(GNEPathElement* pathElement, SUMOVehicleClass vClass, GNELane* fromLane, GNELane* toLane);
167
169 void calculatePath(GNEPathElement* pathElement, SUMOVehicleClass vClass, GNELane* fromLane, GNEJunction* toJunction);
170
172 void calculatePath(GNEPathElement* pathElement, SUMOVehicleClass vClass, GNEJunction* fromJunction, GNELane* toLane);
173
175 void calculatePath(GNEPathElement* pathElement, SUMOVehicleClass vClass, GNEJunction* fromJunction, GNEJunction* toJunction);
176
178 void calculatePath(GNEPathElement* pathElement, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges);
179
181 void calculateConsecutivePathEdges(GNEPathElement* pathElement, SUMOVehicleClass vClass, const std::vector<GNEEdge*>& edges,
182 const int firstLaneIndex = -1, const int lastLaneIndex = -1);
183
185 void calculateConsecutivePathLanes(GNEPathElement* pathElement, const std::vector<GNELane*>& lanes);
186
188 void removePath(GNEPathElement* pathElement);
189
191 void drawLanePathElements(const GUIVisualizationSettings& s, const GNELane* lane) const;
192
194 void drawJunctionPathElements(const GUIVisualizationSettings& s, const GNEJunction* junction) const;
195
197 void redrawPathElements(const GUIVisualizationSettings& s) const;
198
200 void invalidateLanePath(const GNELane* lane);
201
203 void invalidateJunctionPath(const GNEJunction* junction);
204
206 void clearSegments();
207
208protected:
210 void addSegmentInLaneSegments(GNESegment* segment, const GNELane* lane);
211
213 void addSegmentInJunctionSegments(GNESegment* segment, const GNEJunction* junction);
214
217
219 bool connectedLanes(const GNELane* fromLane, const GNELane* toLane) const;
220
222 void buildPath(GNEPathElement* pathElement, SUMOVehicleClass vClass, const std::vector<GNEEdge*> path,
223 GNELane* fromLane, GNEJunction* fromJunction, GNELane* toLane, GNEJunction* toJunction);
224
227
230
232 std::map<const GNEPathElement*, std::vector<GNESegment*> > myPaths;
233
235 std::map<const GNELane*, std::set<GNESegment*> > myLaneSegments;
236
238 std::map<const GNEJunction*, std::set<GNESegment*> > myJunctionSegments;
239
241 bool myCleaningSegments = false;
242
243private:
245 void markLabelSegment(const std::vector<GNESegment*>& segments) const;
246
248 const std::vector<GNESegment*> myEmptySegments;
249
252
255};
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
An Element which don't belong to GNENet but has influence in the simulation.
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
class used to calculate paths in nets
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges) const
calculate Dijkstra path between a list of edges (for example, from-via-to edges)
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutive edges for the given VClass
void updatePathCalculator()
update DijkstraRouter (needed a good calculation of dijkstra path after modifying network)
bool isPathCalculatorUpdated() const
check if pathCalculator is updated
SUMOAbstractRouter< NBRouterEdge, NBVehicle > * myDijkstraRouter
SUMO Abstract myDijkstraRouter.
void invalidatePathCalculator()
invalidate pathCalculator
void calculateReachability(const SUMOVehicleClass vClass, GNEEdge *originEdge)
calculate reachability for given edge
std::vector< GNEEdge * > optimizeJunctionPath(const std::vector< GNEEdge * > &edges) const
optimize junction path
bool myPathCalculatorUpdated
flag for checking if path calculator is updated
bool busStopConnected(const GNEAdditional *busStop, const GNEEdge *edge) const
check if exist a path between the given busStop and edge (Either a valid lane or an acces) for pedest...
const GNENet * myNet
pointer to net
class used to mark path draw
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, SumoXMLTag tag)
check if path element geometry must be drawn in the given lane
std::map< const std::pair< const GNELane *, const GNELane * >, std::set< SumoXMLTag > > myLane2laneDrawedElements
map for saving tags drawn in junctions
void clearPathDraw()
clear path draw
std::map< const GNELane *, std::set< SumoXMLTag > > myLaneDrawedElements
map for saving tags drawn in lanes
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void buildPath(GNEPathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEEdge * > path, GNELane *fromLane, GNEJunction *fromJunction, GNELane *toLane, GNEJunction *toJunction)
build path
void calculatePath(GNEPathElement *pathElement, SUMOVehicleClass vClass, GNELane *fromLane, GNELane *toLane)
calculate path between from-to edges (using dijkstra, require path calculator updated)
void invalidateJunctionPath(const GNEJunction *junction)
invalidate junction path
const std::vector< GNESegment * > & getPathElementSegments(GNEPathElement *pathElement) const
get path segments
const GNEPathElement * getPathElement(const GUIGlObject *GLObject) const
get path element
PathDraw * getPathDraw()
obtain instance of PathDraw
GNEPathManager & operator=(const GNEPathManager &)=delete
Invalidated assignment operator.
void clearSegments()
clear segments
void addSegmentInLaneSegments(GNESegment *segment, const GNELane *lane)
add segments int laneSegments (called by GNESegment constructor)
PathCalculator * myPathCalculator
PathCalculator instance.
void invalidateLanePath(const GNELane *lane)
invalidate lane path
void markLabelSegment(const std::vector< GNESegment * > &segments) const
mark label segment
void calculateConsecutivePathLanes(GNEPathElement *pathElement, const std::vector< GNELane * > &lanes)
calculate consecutive path lanes
bool connectedLanes(const GNELane *fromLane, const GNELane *toLane) const
check if given lanes are connected
void drawLanePathElements(const GUIVisualizationSettings &s, const GNELane *lane) const
draw lane path elements
bool isPathValid(const GNEPathElement *pathElement) const
check if path element is valid
std::map< const GNEJunction *, std::set< GNESegment * > > myJunctionSegments
map with junction segments
GNEPathManager(const GNEPathManager &)=delete
Invalidated copy constructor.
void removePath(GNEPathElement *pathElement)
remove path
void drawJunctionPathElements(const GUIVisualizationSettings &s, const GNEJunction *junction) const
draw junction path elements
const GNELane * getFirstLane(const GNEPathElement *pathElement) const
get first lane associated with path element
bool myCleaningSegments
flag for clear segments quickly
PathDraw * myPathDraw
PathDraw instance.
void clearSegmentFromJunctionAndLaneSegments(GNESegment *segment)
clear segments from junction and lane Segments (called by GNESegment destructor)
std::map< const GNELane *, std::set< GNESegment * > > myLaneSegments
map with lane segments
~GNEPathManager()
destructor
void addSegmentInJunctionSegments(GNESegment *segment, const GNEJunction *junction)
add segments int junctionSegments (called by GNESegment constructor)
void calculateConsecutivePathEdges(GNEPathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges, const int firstLaneIndex=-1, const int lastLaneIndex=-1)
calculate consecutive path edges
void redrawPathElements(const GUIVisualizationSettings &s) const
redraw path elements saved in gViewObjectsHandler buffer
std::map< const GNEPathElement *, std::vector< GNESegment * > > myPaths
map with path element and their associated segments
const std::vector< GNESegment * > myEmptySegments
empty segments (used in getPathElementSegments)
Stores the information about how to visualize structures.