Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSTrainHelper.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2014-2025 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// A class that helps computing positions of a train's carriages.
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <utils/geom/Position.h>
25#include "MSVehicleControl.h"
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30class MSVehicle;
31
32
33// ===========================================================================
34// class definitions
35// ===========================================================================
43public:
44 struct Carriage {
47 std::vector<Position> doorPositions;
48 std::vector<Position> unboardingPositions;
49 };
50
51 MSTrainHelper(const MSVehicle* vehicle, double scaledLength = -1, bool reversed = false,
52 bool secondaryShape = false, double exaggeration = 1.0, int vehicleQuality = 3)
53 : myTrain(vehicle) {
54 computeTrainDimensions(exaggeration, secondaryShape, scaledLength < 0 ? myTrain->getLength() : scaledLength, vehicleQuality);
55 computeCarriages(reversed, secondaryShape);
56 }
57
59 for (const Carriage* carriage : myCarriages) {
60 delete carriage;
61 }
62 }
63
64 inline double getUpscaleLength() const {
65 return myUpscaleLength;
66 }
67
68 inline double getHalfWidth() const {
69 return myHalfWidth;
70 }
71
72 inline int getNumCarriages() const {
73 return myNumCarriages;
74 }
75
76 inline double getCarriageLength() const {
77 return myCarriageLength;
78 }
79
80 inline double getFirstCarriageLength() const {
82 }
83
84 inline int getCarriageDoors() const {
85 return myCarriageDoors;
86 }
87
88 inline int getFirstCarriageNo() const {
89 return myFirstCarriageNo;
90 }
91
92 inline int getFirstPassengerCarriage() const {
94 }
95
96 inline bool isReversed() const {
97 return myIsReversed;
98 }
99
100 inline const std::vector<Carriage*>& getCarriages() const {
101 return myCarriages;
102 }
103
107
110 void computeUnboardingPositions(double passengerRadius, std::vector<Position>& unboardingPositions);
111
113 static double getUpscaleLength(double upscale, double length, double width, int vehicleQuality);
114
117
118private:
119 void computeTrainDimensions(double exaggeration, bool secondaryShape, double scaledLength, int vehicleQuality);
120 void computeCarriages(bool reversed, bool secondaryShape);
121
127 double myLength;
138 std::vector<Carriage*> myCarriages;
139};
A class that helps computing positions of a train's carriages and additional structures.
int getFirstCarriageNo() const
double myFirstCarriageLength
void computeTrainDimensions(double exaggeration, bool secondaryShape, double scaledLength, int vehicleQuality)
const MSVehicle * myTrain
double getFirstCarriageLength() const
static const double PEDESTRIAN_RADIUS_EXTRA_TOLERANCE
small extra tolerance used to avoid constraint violations
std::vector< Carriage * > myCarriages
void computeDoorPositions()
compute door positions on demand and fills the carriage structures
double myLocomotiveLength
bool isReversed() const
const std::vector< Carriage * > & getCarriages() const
double myCarriageLengthWithGap
double getCarriageLength() const
void computeUnboardingPositions(double passengerRadius, std::vector< Position > &unboardingPositions)
compute unboarding positions on demand and fills the carriage structures
double myDefaultLength
int myFirstPassengerCarriage
int getNumCarriages() const
double myCarriageLength
double getUpscaleLength() const
int getCarriageDoors() const
int getFirstPassengerCarriage() const
MSTrainHelper(const MSVehicle *vehicle, double scaledLength=-1, bool reversed=false, bool secondaryShape=false, double exaggeration=1.0, int vehicleQuality=3)
double myUpscaleLength
double getHalfWidth() const
void computeCarriages(bool reversed, bool secondaryShape)
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
std::vector< Position > unboardingPositions
std::vector< Position > doorPositions