27 #define RailEdge_DEBUGID ""
29 #define RailEdge_DEBUG_COND(obj) (true)
35 template<
class E,
class V>
48 RailEdge(
const E* turnStart,
const E* turnEnd,
int numericalID) :
50 myID(
"TrainReversal!" + turnStart->
getID() +
"->" + turnEnd->
getID()),
56 myViaSuccessors.push_back(std::make_pair(turnEnd->getRailwayRoutingEdge(),
nullptr));
59 void update(
double maxTrainLength,
const std::vector<const E*>& replacementEdges) {
63 #ifdef RailEdge_DEBUG_INIT
70 std::vector<_RailEdge*>& railEdges,
int& numericalID,
double dist,
71 double maxTrainLength,
const std::vector<const E*>& replacementEdges) {
74 #ifdef RailEdge_DEBUG_INIT
75 std::cout <<
"addVirtualTurns forward=" << forward->getID() <<
" backward=" << backward->getID() <<
" dist=" << dist
76 <<
" maxLength=" << maxTrainLength <<
" repl=" <<
toString(replacementEdges) <<
"\n";
81 for (
const E* prev : forward->getPredecessors()) {
82 if (prev == backward) {
85 const E* bidi = prev->getBidiEdge();
87 _RailEdge* prevRailEdge = prev->getRailwayRoutingEdge();
92 #ifdef RailEdge_DEBUG_INIT
93 std::cout <<
" RailEdge " << prevRailEdge->
getID() <<
" virtual turnaround " << prevRailEdge->
myTurnaround->
getID() <<
"\n";
96 prevRailEdge->
myTurnaround->
update(prev->getLength() + maxTrainLength, replacementEdges);
97 std::vector<const E*> replacementEdges2;
98 replacementEdges2.push_back(prev);
99 replacementEdges2.insert(replacementEdges2.end(), replacementEdges.begin(), replacementEdges.end());
100 addVirtualTurns(prev, bidi, railEdges, numericalID, dist - prev->getLength(),
101 maxTrainLength + prev->getLength(), replacementEdges2);
106 void init(std::vector<_RailEdge*>& railEdges,
int& numericalID,
double maxTrainLength) {
108 for (
const auto& viaPair :
myOriginal->getViaSuccessors()) {
109 if (viaPair.first ==
myOriginal->getBidiEdge()) {
115 #ifdef RailEdge_DEBUG_INIT
123 myViaSuccessors.push_back(std::make_pair(viaPair.first->getRailwayRoutingEdge(),
124 viaPair.second ==
nullptr ?
nullptr : viaPair.second->getRailwayRoutingEdge()));
127 #ifdef RailEdge_DEBUG_SUCCESSORS
130 std::cout <<
" " << viaPair.first->getID() <<
"\n";
163 into.push_back(edge);
165 seen += edge->getLength();
166 if (seen >= length && edge->isConnectedTo(*edge->getBidiEdge(),
SVC_IGNORING)) {
171 const int last = (int)into.size() - 1;
172 for (
int i = 0; i < nPushed; i++) {
173 into.push_back(into[last - i]->getBidiEdge());
194 #ifdef RailEdge_DEBUG_TURNS
196 std::cout <<
getID() <<
" maxLength=" <<
myMaxLength <<
" veh=" << vehicle->getID() <<
" length=" << vehicle->getLength() <<
"\n";
211 FXMutexLock lock(mySuccessorMutex);
222 if (viaPair.first->myOriginal ==
nullptr
223 || viaPair.first->myOriginal->isTazConnector()
224 ||
myOriginal->isConnectedTo(*viaPair.first->myOriginal, vClass)) {
225 result.push_back(viaPair);
257 mutable FXMutex mySuccessorMutex;
#define RailEdge_DEBUG_COND(obj)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
the edge type representing backward edges
double myStartLength
length of the edge where this turn starts
void insertOriginalEdges(double length, std::vector< const E * > &into) const
int getNumericalID() const
Returns the index (numeric id) of the edge.
const E * getOriginal() const
Returns the original edge.
ConstEdgePairVector myViaSuccessors
std::vector< const E * > myReplacementEdges
actual edges to return when passing this (turnaround) edge - only forward
void addVirtualTurns(const E *forward, const E *backward, std::vector< _RailEdge * > &railEdges, int &numericalID, double dist, double maxTrainLength, const std::vector< const E * > &replacementEdges)
double getLength() const
Returns the length of the edge.
double myMaxLength
maximum train length for passing this (turnaround) edge
bool prohibits(const V *const vehicle) const
RailEdge< E, V > _RailEdge
bool restricts(const V *const vehicle) const
std::map< SUMOVehicleClass, ConstEdgePairVector > myClassesViaSuccessorMap
The successors available for a given vClass.
std::vector< std::pair< const _RailEdge *, const _RailEdge * > > ConstEdgePairVector
void init(std::vector< _RailEdge * > &railEdges, int &numericalID, double maxTrainLength)
const ConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
RailEdge(const E *turnStart, const E *turnEnd, int numericalID)
void update(double maxTrainLength, const std::vector< const E * > &replacementEdges)
const std::string & getID() const
Returns the id of the edge.