Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 {
55 computeTrainDimensions(exaggeration, secondaryShape, scaledLength < 0 ? myTrain->getLength() : scaledLength, vehicleQuality);
56 computeCarriages(reversed, secondaryShape);
57 }
58
60 for (const Carriage* carriage : myCarriages) {
61 delete carriage;
62 }
63 }
64
65 inline double getUpscaleLength() const {
66 return myUpscaleLength;
67 }
68
69 inline double getHalfWidth() const {
70 return myHalfWidth;
71 }
72
73 inline int getNumCarriages() const {
74 return myNumCarriages;
75 }
76
77 inline double getCarriageLength() const {
78 return myCarriageLength;
79 }
80
81 inline double getFirstCarriageLength() const {
83 }
84
85 inline int getCarriageDoors() const {
86 return myCarriageDoors;
87 }
88
89 inline int getFirstCarriageNo() const {
90 return myFirstCarriageNo;
91 }
92
93 inline int getFirstPassengerCarriage() const {
95 }
96
97 inline bool isReversed() const {
98 return myIsReversed;
99 }
100
101 inline const std::vector<Carriage*>& getCarriages() const {
102 return myCarriages;
103 }
104
108
111 void computeUnboardingPositions(double passengerRadius, std::vector<Position>& unboardingPositions);
112
114 static double getUpscaleLength(double upscale, double length, double width, int vehicleQuality);
115
118
119private:
120 void computeTrainDimensions(double exaggeration, bool secondaryShape, double scaledLength, int vehicleQuality);
121 void computeCarriages(bool reversed, bool secondaryShape);
122
128 double myLength;
139 std::vector<Carriage*> myCarriages;
140};
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