27 #define RailEdge_DEBUGID ""
29 #define RailEdge_DEBUG_COND(obj) (true)
31 #define REVERSAL_SLACK (POSITION_EPS + NUMERICAL_EPS)
37 template<
class E,
class V>
50 RailEdge(
const E* turnStart,
const E* turnEnd,
int numericalID) :
52 myID(
"TrainReversal!" + turnStart->
getID() +
"->" + turnEnd->
getID()),
58 myViaSuccessors.push_back(std::make_pair(turnEnd->getRailwayRoutingEdge(),
nullptr));
61 void update(
double maxTrainLength,
const std::vector<const E*>& replacementEdges) {
65 #ifdef RailEdge_DEBUG_INIT
72 std::vector<_RailEdge*>& railEdges,
int& numericalID,
double dist,
73 double maxTrainLength,
const std::vector<const E*>& replacementEdges) {
76 #ifdef RailEdge_DEBUG_INIT
77 std::cout <<
"addVirtualTurns forward=" << forward->getID() <<
" backward=" << backward->getID() <<
" dist=" << dist
78 <<
" maxLength=" << maxTrainLength <<
" repl=" <<
toString(replacementEdges) <<
"\n";
83 for (
const E* prev : forward->getPredecessors()) {
84 if (prev == backward) {
87 const E* bidi = prev->getBidiEdge();
89 _RailEdge* prevRailEdge = prev->getRailwayRoutingEdge();
94 #ifdef RailEdge_DEBUG_INIT
95 std::cout <<
" RailEdge " << prevRailEdge->
getID() <<
" virtual turnaround " << prevRailEdge->
myTurnaround->
getID() <<
"\n";
103 bool notFound =
true;
104 for (
const E* r : replacementEdges) {
114 std::vector<const E*> replacementEdges2;
115 replacementEdges2.push_back(prev);
116 replacementEdges2.insert(replacementEdges2.end(), replacementEdges.begin(), replacementEdges.end());
117 addVirtualTurns(prev, bidi, railEdges, numericalID, dist - prev->getLength(),
118 maxTrainLength + prev->getLength(), replacementEdges2);
124 void init(std::vector<_RailEdge*>& railEdges,
int& numericalID,
double maxTrainLength) {
126 for (
const auto& viaPair :
myOriginal->getViaSuccessors()) {
127 if (viaPair.first ==
myOriginal->getBidiEdge()) {
133 #ifdef RailEdge_DEBUG_INIT
137 #ifdef RailEdge_DEBUG_INIT
144 myViaSuccessors.push_back(std::make_pair(viaPair.first->getRailwayRoutingEdge(),
145 viaPair.second ==
nullptr ?
nullptr : viaPair.second->getRailwayRoutingEdge()));
148 #ifdef RailEdge_DEBUG_SUCCESSORS
151 std::cout <<
" " << viaPair.first->getID() <<
"\n";
184 into.push_back(edge);
186 seen += edge->getLength();
187 if (seen >= length && edge->isConnectedTo(*edge->getBidiEdge(),
SVC_IGNORING)) {
192 const int last = (int)into.size() - 1;
193 for (
int i = 0; i < nPushed; i++) {
194 into.push_back(into[last - i]->getBidiEdge());
215 #ifdef RailEdge_DEBUG_TURNS
217 std::cout <<
getID() <<
" maxLength=" <<
myMaxLength <<
" veh=" << vehicle->getID() <<
" length=" << vehicle->getLength() <<
"\n";
232 FXMutexLock lock(mySuccessorMutex);
243 if (viaPair.first->myOriginal ==
nullptr
244 || viaPair.first->myOriginal->isTazConnector()
245 ||
myOriginal->isConnectedTo(*viaPair.first->myOriginal, vClass)) {
246 result.push_back(viaPair);
278 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.