Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Bogie.h
1// trax track library
2// AD 2014
3//
4// "here in the land of opportunity"
5//
6// New Model Army
7//
8//
9// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
10// Copyright (c) 2019 Marc-Michael Horstmann
11//
12// Permission is hereby granted to any person obtaining a copy of this software
13// and associated source code (the "Software"), to use, view, and study the
14// Software for personal or internal business purposes, subject to the following
15// conditions:
16//
17// 1. Redistribution, modification, sublicensing, or commercial use of the
18// Software is NOT permitted without prior written consent from the copyright
19// holder.
20//
21// 2. The Software is provided "AS IS", without warranty of any kind, express
22// or implied.
23//
24// 3. All copies of the Software must retain this license notice.
25//
26// For further information, please contact: horstmann.marc@trendverlag.de
27
28#pragma once
29
30#include "RailRunner.h"
31
32#include "trax/Simulated.h"
33#include "spat/Frame.h"
34#include "spat/Sphere.h"
35
36namespace trax{
37
38 struct Gestalt;
39 struct RollingStock;
40 struct Scene;
41
65 struct Bogie : RailRunner,
67 {
72 static dclspc std::shared_ptr<Bogie> Make( Scene& scene, std::shared_ptr<Gestalt> pGestalt = nullptr ) noexcept;
73
74
76 virtual std::shared_ptr<Bogie> ThisBogie() const noexcept = 0;
77
78
79 virtual Gestalt& GetGestalt() const noexcept = 0;
80
81
83 virtual RollingStock* GetRollingStock() const noexcept = 0;
84
85
86 // Bogies's arrangement:
87
97
109 virtual void Attach( std::shared_ptr<Bogie> pChildBogie, EndType atEnd, const spat::Frame<Length,One>& swivelPose ) = 0;
110
118 virtual void Attach( std::shared_ptr<Bogie> pChildBogie, EndType atEnd ) = 0;
120
121
127 virtual std::pair<std::shared_ptr<Bogie>,spat::Frame<Length,One>> GetChild( EndType atEnd ) const noexcept = 0;
128
129
135 virtual std::pair<std::shared_ptr<Bogie>,spat::Frame<Length,One>> GetParent( EndType atEnd = EndType::any ) const noexcept = 0;
136
137
139 virtual std::shared_ptr<Bogie> GetFirst() const noexcept = 0;
140
141
146 virtual std::shared_ptr<Bogie> GetNext() const noexcept = 0;
147
148
153 virtual std::shared_ptr<Bogie> GetPrevious() const noexcept = 0;
154
155
157 virtual std::shared_ptr<Bogie> GetLast() const noexcept = 0;
158
159
161 virtual void Detach( EndType atEnd = EndType::all ) noexcept = 0;
162
163
164
165 // Coupling:
166
183 virtual bool Couple( EndType end, Bogie& with, EndType withEnd, bool btriggerPulses = true ) noexcept = 0;
184
185
190 virtual std::pair<std::shared_ptr<Bogie>,EndType> GetCoupledBogie( EndType end ) const noexcept = 0;
191
192
208
209
212 virtual void SetCouplingProps( EndType atEnd, const CouplingProps& props ) = 0;
213
214
216 virtual CouplingProps GetCouplingProps( EndType atEnd ) const noexcept = 0;
217
218
219 virtual spat::Sphere<Length> GetCoupling( EndType end ) const noexcept = 0;
220
221
229 virtual void SetCouplingHeight( EndType end, Length height ) = 0;
230
231
239 virtual bool BreakCoupling( EndType atEnd, bool btriggerPulses = true ) noexcept = 0;
240
241
242
243 // Jacks 'N Plugs:
244
247 virtual Jack& JackOnMotorStart() noexcept = 0;
248
249
252 virtual Jack& JackOnMotorStop() noexcept = 0;
253
254
257 virtual Jack& JackOnBrakeApply() noexcept = 0;
258
259
262 virtual Jack& JackOnBrakeRelease() noexcept = 0;
263
264
269
270
274 virtual Jack& JackOnNorthSwivelBendingIn() noexcept = 0;
275
276
280 virtual Jack& JackOnNorthSwivelBendingOut() noexcept = 0;
281
282
286 virtual Jack& JackOnSouthSwivelBendingIn() noexcept = 0;
287
288
292 virtual Jack& JackOnSouthSwivelBendingOut() noexcept = 0;
293 };
294
295 dclspc bool Couple( std::pair<Bogie&,RailRunner::EndType> a, std::pair<Bogie&,RailRunner::EndType> b ) noexcept;
296
297 dclspc bool AreCoupled( const Bogie& a, const Bogie& b ) noexcept;
298
299 dclspc Length GetCouplingDistance( std::pair<const Bogie&,RailRunner::EndType> a, std::pair<const Bogie&,RailRunner::EndType> b ) noexcept;
300}
301
constexpr Force infinite__force
Dimensionated infinite values.
Definition DimensionedValues.h:368
Value< Dimension< 0, 0, 0 > > One
Dimensionless value.
Definition DimensionedValues.h:319
Value< Dimension< 1, 0, 0 > > Length
Length.
Definition DimensionedValues.h:324
constexpr Real _m(Length l) noexcept
Dimensionated Values conversion functions.
Definition DimensionedValues.h:1210
constexpr Real _N(Force f) noexcept
Dimensionated Values conversion functions.
Definition DimensionedValues.h:1551
Value< Dimension< 1, 1, -2 > > Force
Force.
Definition DimensionedValues.h:333
Value< Dimension< 1, 1, -1 > > Momentum
Momentum.
Definition DimensionedValues.h:335
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
constexpr Position< Valtype > Origin3D
Origin of coordinate system.
Definition Position.h:143
STL namespace.
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
Sphere with center and radius.
Definition Sphere.h:39
Describing data of a coupling.
Definition Bogie.h:194
spat::Sphere< Length > Position
Position and trigger radius of the coupling relative to the bogie's body frame.
Definition Bogie.h:202
BreakingType
Definition Bogie.h:195
@ onMomentumConsumedWithRecuperation
The coupling breaks if the momentum is consumed, but the momentum can be recuperated.
Definition Bogie.h:199
@ onNever
The coupling never breaks.
Definition Bogie.h:196
@ onForceLimitReached
The coupling breaks if the force limit is reached.
Definition Bogie.h:197
@ onMomentumConsumed
The coupling breaks if the momentum is consumed.
Definition Bogie.h:198
Force RecuperationForce
Force to recuperate the spare momentum of the coupling.
Definition Bogie.h:205
Force BreakingForce
Breaking force of the coupling. infinite for unbreakable.
Definition Bogie.h:203
Momentum BreakingSpareMomentum
Breaking momentum of the coupling to be consumed, before the coupling breaks.
Definition Bogie.h:204
int CouplingTypeIdx
Index of the coupling type. Only coupling with same index greater 0 can be coupled.
Definition Bogie.h:206
A Bogie is a RailRunner that can be attached to another Bogie by a swivel and can be coupled to anoth...
Definition Bogie.h:67
virtual void SetCouplingHeight(EndType end, Length height)=0
Sets the height of the coupling over the track.
virtual void Detach(EndType atEnd=EndType::all) noexcept=0
Detaches a bogie from its parent(s).
virtual RollingStock * GetRollingStock() const noexcept=0
virtual Jack & JackOnSouthSwivelBendingIn() noexcept=0
Gets a Jack that pulses its Plug if the Bogie's hinge, that connects it to its south child,...
virtual std::shared_ptr< Bogie > GetPrevious() const noexcept=0
Gets the previous bogie in the rolling stock.
virtual Jack & JackOnCouplingForceLimitExceeded(EndType end)=0
Gets a Jack that pulses its Plug if one (or any) of the RailRunner's outmost couplings experiences a ...
virtual Jack & JackOnSouthSwivelBendingOut() noexcept=0
Gets a Jack that pulses its Plug if the Bogie's hinge, that connects it to its south child,...
virtual Jack & JackOnBrakeRelease() noexcept=0
Gets a Jack that pulses its Plug if the WheelFrame's brakes are released, i.e. if the braking value i...
virtual Jack & JackOnBrakeApply() noexcept=0
Gets a Jack that pulses its Plug if the WheelFrame's brakes are applied, i.e. if the braking value is...
virtual std::pair< std::shared_ptr< Bogie >, spat::Frame< Length, One > > GetChild(EndType atEnd) const noexcept=0
Gets the a pointer to a child bogie and the pose relative to this Bogie, were the swivel axis is runn...
virtual std::shared_ptr< Bogie > GetFirst() const noexcept=0
Gets the first bogie in the rolling stock.
virtual void SetCouplingProps(EndType atEnd, const CouplingProps &props)=0
Sets the coupling properties.
virtual Jack & JackOnNorthSwivelBendingIn() noexcept=0
Gets a Jack that pulses its Plug if the Bogie's hinge, that connects it to its north child,...
virtual std::shared_ptr< Bogie > GetNext() const noexcept=0
Gets the next bogie in the rolling stock.
virtual Jack & JackOnNorthSwivelBendingOut() noexcept=0
Gets a Jack that pulses its Plug if the Bogie's hinge, that connects it to its north child,...
virtual Jack & JackOnMotorStart() noexcept=0
Gets a Jack that pulses its Plug if the RailRunner's motor starts, i.e. if the thrust is set to nonze...
virtual void Attach(std::shared_ptr< Bogie > pChildBogie, EndType atEnd, const spat::Frame< Length, One > &swivelPose)=0
virtual Jack & JackOnMotorStop() noexcept=0
Gets a Jack that pulses its Plug if the RailRunner's motor stops, i.e. if the thrust is set to zero.
virtual bool BreakCoupling(EndType atEnd, bool btriggerPulses=true) noexcept=0
Breaks (not uncouples) the coupling at the enoted end.
virtual std::shared_ptr< Bogie > GetLast() const noexcept=0
Gets the last bogie in the rolling stock.
virtual bool Couple(EndType end, Bogie &with, EndType withEnd, bool btriggerPulses=true) noexcept=0
Couples this Bogie with another at the respective ends.
static dclspc std::shared_ptr< Bogie > Make(Scene &scene, std::shared_ptr< Gestalt > pGestalt=nullptr) noexcept
Makes a Bogie object.
virtual CouplingProps GetCouplingProps(EndType atEnd) const noexcept=0
Gets the coupling properties.
virtual std::shared_ptr< Bogie > ThisBogie() const noexcept=0
Gets a shared pointer to this.
virtual std::pair< std::shared_ptr< Bogie >, EndType > GetCoupledBogie(EndType end) const noexcept=0
Get the coupled Bogie.
virtual std::pair< std::shared_ptr< Bogie >, spat::Frame< Length, One > > GetParent(EndType atEnd=EndType::any) const noexcept=0
Gets the a pointer to a parent bogie and the pose relative to this Bogie, were the swivel axis is r...
A Gestalt is a Body with a Shape.
Definition Gestalt.h:100
A jack a plug can get connected with.
Definition Jack.h:83
Interface for train and rolling stock that can be railed on a track and might provide brakes and powe...
Definition RailRunner.h:345
EndType
Types of the RailRunner's end's.
Definition RailRunner.h:351
@ any
Denotes the north or south end of a Railrunner.
Definition RailRunner.h:355
@ all
Denotes both ends of a RailRunner.
Definition RailRunner.h:356
A RollingStock is a RailRunner that manages one or more connected Bogies.
Definition RollingStock.h:45
A physical simulation scene for running a simulation and creating physical objects in the scene.
Definition Scene.h:72
A simulated object. Register the object with a scene to get called back for Update,...
Definition Simulated.h:39