NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
netlink.h
Go to the documentation of this file.
1
18#ifndef NeTrainSim_NetLink_h
19#define NeTrainSim_NetLink_h
20
21#include <string>
22#include <iostream>
23#include <map>
24#include "../util/vector.h"
25#include <memory>
26
27class NetNode; // Forward declaration of NetNode class
28class Train; // Forward declaration of Train class
29
30using namespace std;
31
36class NetLink {
37private:
38 static unsigned int NumberOfLinksInSimulator;
40public:
41 int id;
42 int userID;
43 std::shared_ptr<NetNode> fromLoc;
44 std::shared_ptr<NetNode> toLoc;
46 double length;
49 map<int, double> grade;
50 double curvature;
53 std::string region;
56 double cost;
80 NetLink(int simulatorID, int linkID, std::shared_ptr<NetNode> fromNode,
81 std::shared_ptr<NetNode> toNode, double maxSpeed,
82 int trafficSignalID, string signalAtEnd, double linkGrade,
83 double linkCurvature, int linkNoOfDirections,
84 double speedVariationfactor, bool isCatenaryAvailable,
85 string linkInRegion, double maxSpeedScale);
86
90 ~NetLink();
91
96 void setLinkSimulatorID(int newID);
97
102 static unsigned int getNumberOfLinks();
103
108 void updateLinksScaleFreeSpeed(double newScale);
109
115 map<int, double> setGrade(double grade);
116
121 double getCost();
122
130 std::pair<std::pair<double, double>, std::pair<double, double>> vectorizeLinkOfOneSegment(std::shared_ptr <NetNode> startNode);
131
132 pair<double, double> findPositionOnLink(double travelledLength, std::shared_ptr<NetNode> startNode);
133
134
135private:
158 std::pair<double, double> getPositionOnVector(std::pair<std::pair<double, double>, std::pair<double, double>>vector,
159 double travelledDistanceOnXAxis);
160
164 void updateLength();
165
191 std::pair<double, double> projectLengthonPathVector(std::pair<double, double>& vectorEndpoints, double length);
192};
193
194
195
202ostream& operator<<(ostream& ostr, const NetLink& link);
203
204#endif // !NeTrainSim_NetLink_h
The NetNode class represents a network node in a simulation.
Definition netnode.h:35
A train.
Definition train.h:42
A vector.
Definition vector.h:24