Eclipse SUMO - Simulation of Urban MObility
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-2024 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 // ===========================================================================
30 class MSVehicle;
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
43 public:
44  struct Carriage {
47  std::vector<Position> doorPositions;
48  std::vector<Position> unboardingPositions;
49  };
50 
51  MSTrainHelper(const MSVehicle* vehicle, bool reversed = false, bool secondaryShape = false, double exaggeration = 1.0, int vehicleQuality = 3)
52  : myTrain(vehicle) {
53  computeTrainDimensions(exaggeration, vehicleQuality);
54  computeCarriages(reversed, secondaryShape);
55  }
56 
58  for (const Carriage* carriage : myCarriages) {
59  delete carriage;
60  }
61  }
62 
63  inline double getUpscaleLength() const {
64  return myUpscaleLength;
65  }
66 
67  inline double getHalfWidth() const {
68  return myHalfWidth;
69  }
70 
71  inline int getNumCarriages() const {
72  return myNumCarriages;
73  }
74 
75  inline double getCarriageLength() const {
76  return myCarriageLength;
77  }
78 
79  inline double getFirstCarriageLength() const {
80  return myFirstCarriageLength;
81  }
82 
83  inline int getCarriageDoors() const {
84  return myCarriageDoors;
85  }
86 
87  inline int getFirstCarriageNo() const {
88  return myFirstCarriageNo;
89  }
90 
91  inline int getFirstPassengerCarriage() const {
93  }
94 
95  inline bool isReversed() const {
96  return myIsReversed;
97  }
98 
99  inline const std::vector<Carriage*>& getCarriages() const {
100  return myCarriages;
101  }
102 
105  void computeDoorPositions();
106 
109  void computeUnboardingPositions(double passengerRadius, std::vector<Position>& unboardingPositions);
110 
112  static double getUpscaleLength(double upscale, double length, int vehicleQuality);
113 
115  static const double CARRIAGE_DOOR_WIDTH;
116 
119 
120 private:
121  void computeTrainDimensions(double exaggeration, int vehicleQuality);
122  void computeCarriages(bool reversed, bool secondaryShape);
123 
129  double myLength;
130  double myHalfWidth;
139  std::vector<Carriage*> myCarriages;
140 };
A class that helps computing positions of a train's carriages and additional structures.
Definition: MSTrainHelper.h:42
void computeTrainDimensions(double exaggeration, int vehicleQuality)
const std::vector< Carriage * > & getCarriages() const
Definition: MSTrainHelper.h:99
int getFirstCarriageNo() const
Definition: MSTrainHelper.h:87
double myFirstCarriageLength
const MSVehicle * myTrain
double getFirstCarriageLength() const
Definition: MSTrainHelper.h:79
static const double PEDESTRIAN_RADIUS_EXTRA_TOLERANCE
small extra tolerance used to avoid constraint violations
std::vector< Carriage * > myCarriages
double myHalfWidth
MSTrainHelper(const MSVehicle *vehicle, bool reversed=false, bool secondaryShape=false, double exaggeration=1.0, int vehicleQuality=3)
Definition: MSTrainHelper.h:51
void computeDoorPositions()
compute door positions on demand and fills the carriage structures
double myLocomotiveLength
bool isReversed() const
Definition: MSTrainHelper.h:95
double myCarriageLengthWithGap
double getCarriageLength() const
Definition: MSTrainHelper.h:75
void computeUnboardingPositions(double passengerRadius, std::vector< Position > &unboardingPositions)
compute unboarding positions on demand and fills the carriage structures
static const double CARRIAGE_DOOR_WIDTH
average door width used to compute doors positions
double myDefaultLength
int myFirstPassengerCarriage
double myCarriageGap
int getNumCarriages() const
Definition: MSTrainHelper.h:71
double myCarriageLength
double getUpscaleLength() const
Definition: MSTrainHelper.h:63
int getCarriageDoors() const
Definition: MSTrainHelper.h:83
int getFirstPassengerCarriage() const
Definition: MSTrainHelper.h:91
double myUpscaleLength
double getHalfWidth() const
Definition: MSTrainHelper.h:67
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
Definition: MSTrainHelper.h:48
std::vector< Position > doorPositions
Definition: MSTrainHelper.h:47