27#define RailEdge_DEBUGID ""
29#define RailEdge_DEBUG_COND(obj) (true)
31#define REVERSAL_SLACK (POSITION_EPS + NUMERICAL_EPS)
37template<
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));
66 void update(
double maxTrainLength,
const std::vector<const E*>& replacementEdges) {
70#ifdef RailEdge_DEBUG_INIT
77 std::vector<_RailEdge*>& railEdges,
int& numericalID,
double dist,
78 double maxTrainLength,
const std::vector<const E*>& replacementEdges) {
81#ifdef RailEdge_DEBUG_INIT
82 std::cout <<
"addVirtualTurns forward=" << forward->getID() <<
" backward=" << backward->getID() <<
" dist=" << dist
83 <<
" maxLength=" << maxTrainLength <<
" repl=" <<
toString(replacementEdges) <<
"\n";
88 for (
const E* prev : forward->getPredecessors()) {
89 if (prev == backward) {
92 const E* bidi = prev->getBidiEdge();
93 if (bidi !=
nullptr && backward->isConnectedTo(*bidi,
SVC_IGNORING)) {
94 _RailEdge* prevRailEdge = prev->getRailwayRoutingEdge();
99#ifdef RailEdge_DEBUG_INIT
100 std::cout <<
" RailEdge " << prevRailEdge->
getID() <<
" virtual turnaround " << prevRailEdge->
myTurnaround->
getID() <<
"\n";
108 bool notFound =
true;
109 for (
const E* r : replacementEdges) {
119 std::vector<const E*> replacementEdges2;
120 replacementEdges2.push_back(prev);
121 replacementEdges2.insert(replacementEdges2.end(), replacementEdges.begin(), replacementEdges.end());
122 addVirtualTurns(prev, bidi, railEdges, numericalID, dist - prev->getLength(),
123 maxTrainLength + prev->getLength(), replacementEdges2);
129 void init(std::vector<_RailEdge*>& railEdges,
int& numericalID,
double maxTrainLength) {
131 for (
const auto& viaPair :
myOriginal->getViaSuccessors()) {
132 if (viaPair.first ==
myOriginal->getBidiEdge()) {
138#ifdef RailEdge_DEBUG_INIT
142#ifdef RailEdge_DEBUG_INIT
148 const double initialDist =
MAX2(maxTrainLength -
getLength(), POSITION_EPS);
152 myViaSuccessors.push_back(std::make_pair(viaPair.first->getRailwayRoutingEdge(),
153 viaPair.second ==
nullptr ?
nullptr : viaPair.second->getRailwayRoutingEdge()));
156#ifdef RailEdge_DEBUG_SUCCESSORS
159 std::cout <<
" " << viaPair.first->getID() <<
"\n";
193 into.push_back(edge);
197 if (seen >= length && edge->isConnectedTo(*edge->getBidiEdge(),
SVC_IGNORING)) {
201 const int last = (int)into.size() - 1;
202 for (
int i = 0; i < nPushed; i++) {
203 into.push_back(into[last - i]->getBidiEdge());
224#ifdef RailEdge_DEBUG_TURNS
226 std::cout <<
getID() <<
" maxLength=" <<
myMaxLength <<
" veh=" << vehicle->getID() <<
" length=" << vehicle->getLength() <<
"\n";
242 FXMutexLock lock(mySuccessorMutex);
253 if (viaPair.first->myOriginal ==
nullptr
254 || viaPair.first->myOriginal->isTazConnector()
255 ||
myOriginal->isConnectedTo(*viaPair.first->myOriginal, vClass)) {
256 result.push_back(viaPair);
288 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
#define UNUSED_PARAMETER(x)
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.
ConstEdgePairVector myViaSuccessors
const std::string & getID() const
Returns the id of the edge.
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.
virtual ~RailEdge()
Destructor.
const E * getOriginal() const
Returns the original edge.
const ConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
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)
RailEdge(const E *turnStart, const E *turnEnd, int numericalID)
void update(double maxTrainLength, const std::vector< const E * > &replacementEdges)