Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Track.h
Go to the documentation of this file.
1// trax track library
2// AD 2013
3//
4// "I will love you 'till the end of time"
5//
6// Lana Del Rey
9//
10// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
11// Copyright (c) 2019 Marc-Michael Horstmann
12//
13// Permission is hereby granted to any person obtaining a copy of this software
14// and associated source code (the "Software"), to use, view, and study the
15// Software for personal or internal business purposes, subject to the following
16// conditions:
17//
18// 1. Redistribution, modification, sublicensing, or commercial use of the
19// Software is NOT permitted without prior written consent from the copyright
20// holder.
21//
22// 2. The Software is provided "AS IS", without warranty of any kind, express
23// or implied.
24//
25// 3. All copies of the Software must retain this license notice.
26//
27// For further information, please contact: horstmann.marc@trendverlag.de
28
29#pragma once
30
236
237#include "IDType.h"
238#include "Units.h"
239#include "Identified.h"
240#include "Orientation.h"
241#include "RoadwayTwist.h"
242
243#include "common/Interval.h"
244#include "spat/Box.h"
245#include "spat/Frame.h"
246#include "spat/Vector2D.h"
247#include "spat/VectorBundle.h"
248#include "spat/VectorBundle2.h"
249
250namespace trax
251{
252 struct Body;
253 struct Connector;
254 struct Curve;
255 struct Event;
256 struct MovableTrack;
257 struct ParallelizableTrack;
258 struct RoadwayTwist;
259 struct Sensor;
260 struct Signal;
261 struct SignalTarget;
262 template<typename> struct TrackData;
263 struct TrackBuilder;
264 struct TrackLocation;
265 struct TrackRange;
266
268 struct TrackUserData;
269
270
274 struct Track : Identified<Track>
275 {
277 virtual const char* TypeName() const noexcept = 0;
278
279 enum class TrackType : char{
280 unknown = -1,
281 none = 0,
282 standard,
283 withGeoms,
284 movable,
285 movable_autoconnecting,
286 parallel
287 };
288
289 virtual TrackType GetTrackType() const noexcept = 0;
290
292 enum class EndType : char{
293 none = -1,
294 front = 0,
295 end = 1,
297 };
298
299 typedef std::pair<std::shared_ptr<Track>,EndType> TrackEnd;
300 typedef std::pair<std::shared_ptr<const Track>,const EndType> cTrackEnd;
301
303 struct End{
304 End() noexcept = default;
305 End( IDType id, EndType type ) noexcept
306 : id { id },
307 type { type }
308 {}
309
310 End( const TrackEnd& trackEnd ) noexcept
311 : id { trackEnd.first ? trackEnd.first->ID() : IDType{0u} },
312 type { trackEnd.second }
313 {}
314
315 End( const std::pair<std::shared_ptr<TrackBuilder>,Track::EndType>& trackEnd ) noexcept;
316
318 EndType type = EndType::none;
319 };
320
321
329
330
333
335 virtual std::shared_ptr<const TrackBuilder> This() const noexcept = 0;
336
338 virtual std::shared_ptr<TrackBuilder> This() noexcept = 0;
340
341
344
345 virtual std::shared_ptr<const MovableTrack> GetMovableTrack() const noexcept = 0;
346
347 virtual std::shared_ptr<MovableTrack> GetMovableTrack() noexcept = 0;
349
352
353 virtual std::shared_ptr<const ParallelizableTrack> GetParallelizableTrack() const noexcept = 0;
354
355 virtual std::shared_ptr<ParallelizableTrack> GetParallelizableTrack() noexcept = 0;
357
358
360 virtual std::shared_ptr<const Body> GetBody() const noexcept = 0;
361
362
365 virtual bool IsValid() const noexcept = 0;
366
367
369 virtual Length GetLength() const noexcept = 0;
370
371
375 virtual common::Interval<Length> Range() const noexcept = 0;
376
377
379 virtual bool IsCoupled( EndType atend = EndType::any ) const noexcept = 0;
380
381
386 virtual AnglePerLength Curvature( Length s ) const = 0;
387
388
394 virtual AnglePerLength Torsion( Length s ) const = 0;
395
396
398 virtual Angle GetTwistValue( Length s ) const = 0;
399
400
403 virtual AnglePerLength GetTwistD1( Length s ) const = 0;
404
405
407 virtual bool IsFlat() const noexcept = 0;
408
409
416 virtual spat::Vector<One> LocalUp() const = 0;
417
418
426 virtual void TNBFrame( Length s, spat::Frame<Length,One>& frame ) const = 0;
427
428
446
448 virtual void Transition( Length s, spat::Position<Length>& pos ) const = 0;
449
450 virtual void Transition( Length s, spat::Vector<One>& tan ) const = 0;
451
452 virtual void Transition( Length s, spat::VectorBundle<Length,One>& bundle ) const = 0;
453
454 virtual void Transition( Length s, spat::VectorBundle2<Length,One>& bundle ) const = 0;
455
456 virtual void Transition( Length s, spat::Frame<Length,One>& frame ) const = 0;
457
458 virtual void Transition( Length s, TrackData<Real>& td, Real engine_meters_per_unit ) const = 0;
460
461
467 virtual TrackEnd TransitionEnd( EndType thisEnd ) const noexcept = 0;
468
469
478 virtual void DoTrigger( const common::Interval<Length>& range, const Event& _event ) const = 0;
479
480
488 virtual bool DoSignal( const common::Interval<Length>& range, Orientation orientation, SignalTarget& signalTarget ) const = 0;
489
490
496 virtual Signal* GetSignal( const TrackLocation& loc ) const noexcept = 0;
497
498
501 virtual Connector* GetConnector( EndType atend ) const noexcept = 0;
502
503
508 virtual Connector* GetConnector( const Orientation& inDirection ) const noexcept = 0;
509
510
519
532 virtual void Reserve( common::Interval<Length> range, IDType forID ) = 0;
533
535 using ReservationIterator = std::vector<Reservation>::const_iterator;
536
538 virtual ReservationIterator BeginReservations() const noexcept = 0;
539
541 virtual ReservationIterator EndReservations() const noexcept = 0;
542
550 virtual void DeleteReservation( common::Interval<Length> inRange, IDType forID = anyID ) noexcept = 0;
551
552
554 virtual bool IsReserved( common::Interval<Length> inRange, IDType forID = anyID ) const noexcept = 0;
555
556
566
567
575 virtual std::vector<Overlap> Overlaps( IDType forID ) const = 0;
577
578
582 virtual void UserData( TrackUserData* pData ) noexcept = 0;
583
584
586 virtual TrackUserData* UserData() const noexcept = 0;
587 };
588
590 dclspc const char* ToString( Track::TrackType type );
591
593 dclspc Track::TrackType TrackType( const std::string& type ) noexcept;
594
596 inline bool operator==( const Track::End& theone, const Track::End& theother ) noexcept;
597
598
600 inline bool operator!=( const Track::End& theone, const Track::End& theother ) noexcept;
601
602
604 inline bool operator==( const Track::Coupling& theone, const Track::Coupling& theother ) noexcept;
605
606
608 inline bool operator!=( const Track::Coupling& theone, const Track::Coupling& theother ) noexcept;
609
610
611 inline bool operator==( const Track::Overlap& a, const Track::Overlap& b ) noexcept;
612
613 inline bool operator<( const Track::Overlap& a, const Track::Overlap& b ) noexcept;
614
615
617 dclspc std::string ToString( Track::EndType end );
618
619
622 dclspc Track::EndType ToEndType( const std::string& end );
623
624
626 inline Track::EndType operator!( Track::EndType end ) noexcept{
628 }
629
630
679
681 dclspc Length Segment( const Track& track, Length s, Length e, common::Interval<Length> segmentLimits, bool ignoreCuvesTorsion = false );
682
683
695 dclspc Length Segment( const Track& track, Length s, Length e, Length w, Length h, common::Interval<Length> segmentLimits, bool ignoreCuvesTorsion = false );
696
697
703 dclspc Length Segment_Checked( const Track& track, Length s, Length e, common::Interval<Length> segmentLimits, bool ignoreCuvesTorsion = false );
704
705
708 dclspc Length Segment_Checked( const Track& track, Length s, Length e, Length w, Length h, common::Interval<Length> segmentLimits, bool ignoreCuvesTorsion = false );
709
710
715 dclspc Length Segment_TotallyChecked( const Track& track, Length s, Length e, common::Interval<Length> segmentLimits, bool ignoreCuvesTorsion = false );
716
717
720 dclspc Length Segment_TotallyChecked( const Track& track, Length s, Length e, Length w, Length h, common::Interval<Length> segmentLimits, bool ignoreCuvesTorsion = false );
722
723
745
747 dclspc std::pair<bool,Length> Foot( const spat::Position<Length>& ofPoint, const Track& toTrack );
748
749 dclspc std::pair<bool,Length> Foot( const spat::Position<Length>& ofPoint, const Track& toTrack, Length bestGuess );
750
751 dclspc std::pair<bool,Length> Foot( const spat::Position<Length>& ofPoint, const Track& toTrack, Length bestGuess, common::Interval<Length> inRange );
752
754 dclspc std::pair<bool,Length> Foot( const spat::VectorBundle<Length,One>& ofRay, const Track& toTrack );
755
756 dclspc std::pair<bool,Length> Foot( const spat::VectorBundle<Length,One>& ofRay, const Track& toTrack, Length bestGuess );
757
758 dclspc std::pair<bool,Length> Foot( const spat::VectorBundle<Length,One>& ofRay, const Track& toTrack, Length bestGuess, common::Interval<Length> inRange );
760
761
778
780 dclspc Length Closest( const spat::Position<Length>& toPoint, const Track& onTrack, bool includeEndpoints = true );
781
783 dclspc Length Closest( const spat::VectorBundle<Length,One>& toRay, const Track& onTrack, bool includeEndpoints = true );
785
786
801 dclspc void Couple( std::pair<std::shared_ptr<Track>,Track::EndType> trackA, std::pair<std::shared_ptr<Track>,Track::EndType> trackB );
802
803
807 dclspc Length DistanceOf( Track::cTrackEnd trackEndA, Track::cTrackEnd trackEndB );
808
809
813 dclspc Length DistanceToCoupled( const Track& track, Track::EndType atEnd );
814
815
819 dclspc Angle KinkToCoupled( const Track& track, Track::EndType atEnd );
820
821
825 dclspc Angle TwistToCoupled( const Track& track, Track::EndType atEnd );
826
827
828
831 {
833 static dclspc std::shared_ptr<TrackBuilder> Make( TrackType type = TrackType::standard ) noexcept;
834
835
843
845 virtual void SetFrame( const spat::Frame<Length,One>& frame ) noexcept = 0;
846
847
866 virtual void SetFrame( const spat::Frame<Length,One>& start, Length s, bool bAllowTwistOffset = true ) = 0;
868
869
871 virtual const spat::Frame<Length,One>& GetFrame() const noexcept = 0;
872
873
877 virtual const spat::Frame<Length,One>& GetAbsoluteFrame() const noexcept = 0;
878
879
893 virtual void Couple( std::pair<std::shared_ptr<TrackBuilder>,Track::EndType> thisEnd, std::pair<std::shared_ptr<TrackBuilder>,Track::EndType> othersEnd ) = 0;
894
895
900 virtual void DeCouple( EndType thisEnd = EndType::any, bool oneSided = false ) = 0;
901
902
916
918 virtual void Attach( std::shared_ptr<const Curve> pCurve, common::Interval<Length> curveSegment = {0_m,+infinite__length} ) = 0;
919
920 virtual void Attach( std::pair<std::shared_ptr<const Curve>,common::Interval<Length>> curve ) = 0;
921
922 virtual void Attach( std::pair<std::unique_ptr<const Curve>, common::Interval<Length>>& curve ) = 0;
923
924
927 virtual std::pair<std::shared_ptr<const Curve>,common::Interval<Length>> DetachCurve() noexcept = 0;
928
929
931 virtual std::pair<std::shared_ptr<const Curve>,common::Interval<Length>> GetCurve() const noexcept = 0;
933
934
940
942 virtual void Attach( std::unique_ptr<RoadwayTwist> pTwist ) = 0;
943
944
952 virtual std::unique_ptr<RoadwayTwist> DetachTwist() = 0;
953
954
957 virtual RoadwayTwist& GetTwist() const noexcept = 0;
959
960
963
968 virtual void Attach( std::shared_ptr<Sensor> pSensor, const TrackLocation& tracklocation ) = 0;
969
970
972 virtual bool Attached( const Sensor& sensor, TrackLocation* pTrackLocation = nullptr ) const = 0;
973
974
976 virtual void Detach( const Sensor& sensor ) noexcept = 0;
977
978
980 virtual std::shared_ptr<Sensor> GetSensor( int idx ) const noexcept = 0;
981
982
984 virtual int CountSensors() const = 0;
986
987
1001
1003 virtual void Attach( std::shared_ptr<Signal> pSignal, const common::Interval<Length>& trackRange ) = 0;
1004
1006 virtual void Attach( std::shared_ptr<Signal> pSignal, const TrackLocation& location ) = 0;
1007
1008
1010 virtual bool Attached( const Signal& signal, TrackRange* pTrackRange = nullptr ) const = 0;
1011
1012
1015 virtual void Detach( const Signal& signal ) = 0;
1017
1018
1029 virtual void Flip( bool flipAttached = false ) = 0;
1030
1031
1035 virtual void CreateEndTransitionSignal( EndType atend ) = 0;
1036
1037
1040 virtual void DestroyEndTransitionSignal( EndType atend ) = 0;
1041 };
1042
1043
1046 bool dclspc SetFrame( TrackBuilder& track, const spat::Frame<Length,One>& start, Length s ) noexcept;
1047
1048
1055
1056
1084 bool dclspc Strech( TrackBuilder& track,
1086 common::Interval<Length> length_limits = {0_m,+infinite__length},
1087 common::Interval<Length> overshoot_limits = { 0_m, +infinite__length },
1088 const spat::Vector<One>& up = Up,
1089 Length e_length = epsilon__length, Angle e_angle = epsilon__angle );
1090
1093 bool dclspc StrechStart( TrackBuilder& track,
1095 common::Interval<Length> length_limits = {0_m,+infinite__length},
1096 const spat::Vector<One>& up = Up, Length e_length = epsilon__length );
1097
1100 bool dclspc StrechStart( TrackBuilder& track,
1101 spat::Position<Length> start, bool bKeepStartTangent, Length cubicOvershootStart, Length cubicOvershootEnd,
1102 common::Interval<Length> length_limits = {0_m,+infinite__length},
1103 common::Interval<Length> overshoot_limits = { 0_m, +infinite__length },
1104 const spat::Vector<One>& up = Up, Length e_length = epsilon__length, Angle e_angle = epsilon__angle );
1105
1108 bool dclspc StrechStart( TrackBuilder& track,
1109 spat::VectorBundle<Length,One> start, Length cubicOvershootEnd,
1110 common::Interval<Length> length_limits = {0_m,+infinite__length},
1111 common::Interval<Length> overshoot_limits = { 0_m, +infinite__length },
1112 const spat::Vector<One>& up = Up, Length e_length = epsilon__length, Angle e_angle = epsilon__angle );
1113
1116 bool dclspc StrechEnd( TrackBuilder& track,
1118 common::Interval<Length> length_limits = {0_m,+infinite__length},
1119 const spat::Vector<One>& up = Up, Length e_length = epsilon__length );
1120
1123 bool dclspc StrechEnd( TrackBuilder& track,
1124 spat::Position<Length> end, bool bKeepEndTangent, Length cubicOvershootStart, Length cubicOvershootEnd,
1125 common::Interval<Length> length_limits = {0_m,+infinite__length},
1126 common::Interval<Length> overshoot_limits = { 0_m, +infinite__length },
1127 const spat::Vector<One>& up = Up, Length e_length = epsilon__length, Angle e_angle = epsilon__angle );
1128
1131 bool dclspc StrechEnd( TrackBuilder& track,
1132 spat::VectorBundle<Length,One> end, Length cubicOvershootStart,
1133 common::Interval<Length> length_limits = {0_m,+infinite__length},
1134 common::Interval<Length> overshoot_limits = { 0_m, +infinite__length },
1135 const spat::Vector<One>& up = Up, Length e_length = epsilon__length, Angle e_angle = epsilon__angle );
1137
1138
1146 bool dclspc Mirror( TrackBuilder& track,
1147 const spat::VectorBundle<Length,One> mirrorPlane, bool bTest = false );
1148
1149
1161 bool dclspc Normalize( TrackBuilder& track, bool bTest = false );
1162
1163
1174 void dclspc StraightenUp( TrackBuilder& track, const spat::Vector<One>& up = Up );
1175
1176
1184 bool dclspc Simplify( TrackBuilder& track ) noexcept;
1185
1186
1203
1205 //std::shared_ptr<TrackBuilder> dclspc CopyTrack( const TrackBuilder& originalTrack, const Factory& factory, bool cloneCurve = false );
1206
1207 std::shared_ptr<TrackBuilder> dclspc CopyTrack( const TrackBuilder& originalTrack, TrackBuilder& copyTrack, bool cloneCurve = false );
1208
1209 std::shared_ptr<TrackBuilder> dclspc CopyTrack( const TrackBuilder& originalTrack, bool cloneCurve = false );
1210
1211 //std::shared_ptr<TrackBuilder> dclspc CopyTrack( const TrackBuilder& originalTrack, const Factory& factory, common::Interval<Length> copyRange, bool cloneCurve = false );
1212
1213 std::shared_ptr<TrackBuilder> dclspc CopyTrack( const TrackBuilder& originalTrack, TrackBuilder& copyTrack, common::Interval<Length> copyRange, bool cloneCurve = false );
1214
1215 std::shared_ptr<TrackBuilder> dclspc CopyTrack( const TrackBuilder& originalTrack, common::Interval<Length> copyRange, bool cloneCurve = false );
1217
1218
1231
1232 //std::vector<std::shared_ptr<TrackBuilder>> dclspc SplitTrack( const TrackBuilder& track, const Factory& factory, int numPieces = 2, bool cloneCurve = false );
1233
1234 std::vector<std::shared_ptr<TrackBuilder>> dclspc SplitTrack( const TrackBuilder& track, int numPieces = 2, bool cloneCurve = false );
1235
1236 //std::vector<std::shared_ptr<TrackBuilder>> dclspc SplitTrack( const TrackBuilder& track, const Factory& factory, Length atParameter, bool cloneCurve = false );
1237
1238 std::vector<std::shared_ptr<TrackBuilder>> dclspc SplitTrack( const TrackBuilder& track, Length atParameter, bool cloneCurve = false );
1240
1241
1252 std::vector<std::shared_ptr<TrackBuilder>> dclspc CloseGap(
1256 const spat::Vector<One>& up = Up,
1257 Length e_length = epsilon__length,
1258 Angle e_angle = epsilon__angle,
1259 bool cloneCurve = false );
1260
1261
1275
1276 spat::VectorBundle2<Length,One> dclspc Parallel( const TrackBuilder& originalTrack, Length s, spat::Vector2D<Length> shift );
1277
1294
1295
1314
1317 std::shared_ptr<TrackBuilder> dclspc MakeParallelTrack(
1318 const TrackBuilder& originalTrack,
1320 spat::Vector2D<Length> shift = spat::Null2D<trax::Length>,
1321 bool bShiftRelativeToTwistOrUp = true,
1322 spat::Vector<One> up = Up,
1323 Length maxDeviationLength = epsilon__length,
1324 Angle maxDeviationAngle = epsilon__angle );
1325
1327 std::shared_ptr<TrackBuilder> dclspc MakeParallelTrackWithPolygonalChain(
1328 const TrackBuilder& originalTrack,
1330 spat::Vector2D<Length> shift = spat::Null2D<trax::Length>,
1331 bool bShiftRelativeToTwistOrUp = true,
1332 spat::Vector<One> up = Up,
1333 Length maxDeviationLength = epsilon__length,
1334 common::Interval<Length> sampleDistanceLimits = { 1_m, 10_m } );
1335
1337 std::shared_ptr<TrackBuilder> dclspc MakeParallelTrackWithSampledCurve(
1338 const TrackBuilder& originalTrack,
1340 spat::Vector2D<Length> shift = spat::Null2D<trax::Length>,
1341 bool bShiftRelativeToTwistOrUp = true,
1342 spat::Vector<One> up = Up,
1343 Length maxDeviationLength = epsilon__length,
1344 Angle maxDeviationAngle = epsilon__angle,
1345 common::Interval<Length> sampleDistanceLimits = { epsilon__length, 20_m } );
1346
1348 std::shared_ptr<TrackBuilder> dclspc MakeParallelTrackWithSpline(
1349 const TrackBuilder& originalTrack,
1352 bool bShiftRelativeToTwistOrUp,
1353 spat::Vector<One> up = Up,
1354 Length maxDeviationLength = epsilon__length,
1355 common::Interval<Length> sampleDistanceLimits = { 1_m, 1000_m } );
1357
1358
1360// inlines:
1361inline Track::End::End( const std::pair<std::shared_ptr<TrackBuilder>,Track::EndType>& trackEnd ) noexcept
1362 : id { trackEnd.first ? trackEnd.first->ID() : IDType{0u} }
1363 , type { trackEnd.second }
1364{}
1365
1366inline bool operator==( const Track::End& theone, const Track::End& theother ) noexcept{
1367 return theone.id == theother.id && theone.type == theother.type;
1368}
1369
1370inline bool operator!=( const Track::End& theone, const Track::End& theother ) noexcept{
1371 return !operator==( theone, theother );
1372}
1373
1374inline bool operator==( const Track::Coupling& a, const Track::Coupling& b ) noexcept{
1375 return a.theOne == b.theOne &&
1376 a.theOther == b.theOther;
1377}
1378
1379inline bool operator!=( const Track::Coupling& a, const Track::Coupling& b ) noexcept{
1380 return !operator==( a, b );
1381}
1382
1383inline bool operator==( const Track::Overlap& a, const Track::Overlap& b ) noexcept{
1384 return a.forID == b.forID &&
1385 a.forNear == b.forNear &&
1386 a.forFar == b.forFar &&
1387 a.withID == b.withID &&
1388 a.withNear == b.withNear &&
1389 a.withFar == b.withFar;
1390}
1391
1392inline bool operator<( const Track::Overlap& a, const Track::Overlap& b ) noexcept{
1393 if( a.forID < b.forID )
1394 return true;
1395 if( a.forID == b.forID ){
1396 if( a.withID < b.withID )
1397 return true;
1398 if( a.withID == b.withID ){
1399 if( a.forNear < b.forNear )
1400 return true;
1401 if( a.forNear == b.forNear ){
1402 if( a.forFar < b.forFar )
1403 return true;
1404 if( a.forFar == b.forFar ){
1405 if( a.withNear < b.withNear )
1406 return true;
1407 if( a.withNear == b.withNear )
1408 if( a.withFar < b.withFar )
1409 return true;
1410 }
1411 }
1412 }
1413 }
1414
1415 return false;
1416}
1417//
1418//inline bool operator==( const TrackBuilder& tbA, const TrackBuilder& tbB ){
1419// if( !tbA.GetCurve() && tbB.GetCurve() ||
1420// tbA.GetCurve() && !tbB.GetCurve() )
1421// return false;
1422//
1423// if( tbA.GetCurve() && !tbA.GetCurve()->Equal( *tbB.GetCurve() ) )
1424// return false;
1425//
1426// return tbA.ID() == tbB.ID() &&
1427// tbA.Reference( "name" ) == tbB.Reference( "name" ) &&
1428// tbA.GetFrame() == tbB.GetFrame() &&
1429// tbA.GetTwist()->Equal( tbB.GetTwist().get());
1430//}
1431//
1432//inline bool operator!=( const TrackBuilder& tbA, const TrackBuilder& tbB ){
1433// return !(tbA == tbB);
1434//}
1435
1436}
dclspc Length Closest(const spat::Position< Length > &toPoint, const Track &onTrack, bool includeEndpoints=true)
Closest point on a track to a point in space.
dclspc std::pair< bool, Length > Foot(const spat::Position< Length > &ofPoint, const Track &toTrack)
Foot for point in space.
dclspc Length Segment(const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
Calculates a segment length ds so that the visible failure in a track would become smaller than some ...
dclspc Length Segment_TotallyChecked(const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
Works like Segment(), but checks the result.
dclspc Length Segment_Checked(const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
Works like Segment(), but checks the result and shrinks it if necessary.
Namespace of common utility classes and methods.
Definition Helpers.h:43
constexpr bool operator!=(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:701
constexpr bool operator==(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:696
constexpr bool operator<(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Definition Interval.h:657
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 Length infinite__length
Dimensionated infinite values.
Definition DimensionedValues.h:359
Value< Dimension<-1, 0, 0 > > AnglePerLength
Angle per length.
Definition DimensionedValues.h:321
float Real
Underlying floating point type to be used with the dim library.
Definition DimensionedValues.h:190
Value< Dimension< 0, 0, 0 > > Angle
Angle in radians.
Definition DimensionedValues.h:320
constexpr Value< Dimension< 0, 0, 0 > > tan(Value< Dimension< 0, 0, 0 > > a) noexcept
Dimensionated Values math function.
Definition DimensionedValues.h:702
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
auto Normalize(const Frame< Valtype, ValtypeT > &f) noexcept -> std::pair< Vector< ValtypeT >, Frame< Valtype, decltype(ValtypeT{}/ValtypeT{})> >
Outer normalizing.
Definition Frame.h:1144
STL namespace.
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
bool dclspc Strech(TrackBuilder &track, spat::VectorBundle< Length, One > start, spat::VectorBundle< Length, One > end, common::Interval< Length > length_limits={0_m,+infinite__length}, common::Interval< Length > overshoot_limits={ 0_m,+infinite__length }, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle)
bool dclspc StrechStart(TrackBuilder &track, spat::Position< Length > start, common::Interval< Length > length_limits={0_m,+infinite__length}, const spat::Vector< One > &up=Up, Length e_length=epsilon__length)
std::shared_ptr< TrackBuilder > dclspc MakeParallelTrackWithPolygonalChain(const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift=spat::Null2D< trax::Length >, bool bShiftRelativeToTwistOrUp=true, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, common::Interval< Length > sampleDistanceLimits={ 1_m, 10_m })
Parallel approximation by Polygonal Chain.
dclspc Length DistanceToCoupled(const Track &track, Track::EndType atEnd)
spat::VectorBundle2< Length, One > dclspc ParallelToUp(const TrackBuilder &originalTrack, Length s, spat::Vector2D< Length > shift, spat::Vector< One > up=Up)
Parallel with respect to some plane, defined by an up-direction.
void dclspc TransformToNonEEPCurve(TrackBuilder &track)
Creates a matching Curve, Twist and Frame from an EEPCurve.
bool dclspc StrechEnd(TrackBuilder &track, spat::Position< Length > end, common::Interval< Length > length_limits={0_m,+infinite__length}, const spat::Vector< One > &up=Up, Length e_length=epsilon__length)
constexpr spat::Vector< One > Up
Vector pointing in the up direction with respect to gravity.
Definition Units.h:144
bool dclspc Mirror(TrackBuilder &track, const spat::VectorBundle< Length, One > mirrorPlane, bool bTest=false)
Mirrors the track's geometry on a plane.
void dclspc StraightenUp(TrackBuilder &track, const spat::Vector< One > &up=Up)
Some curves maintain a local up direction. It might be pleasing for the user to have his curve straig...
std::shared_ptr< TrackBuilder > dclspc MakeParallelTrack(const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift=spat::Null2D< trax::Length >, bool bShiftRelativeToTwistOrUp=true, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, Angle maxDeviationAngle=epsilon__angle)
Makes a parallel track by trying Line, Arc and Helix first. If that does not apply it returns nullptr...
std::shared_ptr< TrackBuilder > dclspc CopyTrack(const TrackBuilder &originalTrack, TrackBuilder &copyTrack, bool cloneCurve=false)
Creates a new track from a template track.
dclspc Length DistanceOf(Track::cTrackEnd trackEndA, Track::cTrackEnd trackEndB)
bool dclspc SetFrame(TrackBuilder &track, const spat::Frame< Length, One > &start, Length s) noexcept
Same as track.SetFrame( start, s ), but does not throw.
dclspc Track::EndType ToEndType(const std::string &end)
Makes a status value from a status string.
std::vector< std::shared_ptr< TrackBuilder > > dclspc CloseGap(spat::Frame< Length, One > start, spat::Frame< Length, One > end, common::Interval< Length > limits, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle, bool cloneCurve=false)
Creates a series of new tracks that close the gap between start and end.
bool dclspc Simplify(TrackBuilder &track) noexcept
Simplifies the track's curve.
dclspc Angle TwistToCoupled(const Track &track, Track::EndType atEnd)
std::shared_ptr< TrackBuilder > dclspc MakeParallelTrackWithSampledCurve(const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift=spat::Null2D< trax::Length >, bool bShiftRelativeToTwistOrUp=true, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, Angle maxDeviationAngle=epsilon__angle, common::Interval< Length > sampleDistanceLimits={ epsilon__length, 20_m })
Parallel approximation by SampledCurve.
std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > dclspc Couple(const TrackCollection &collection, TrackBuilder &track, Track::EndType endType, Length maxDistance=1_m, Angle maxKink=pi, bool bSilent=true)
Searches open track ends inside an area around a given track end and couples to the closest.
std::shared_ptr< TrackBuilder > dclspc MakeParallelTrackWithSpline(const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift, bool bShiftRelativeToTwistOrUp, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, common::Interval< Length > sampleDistanceLimits={ 1_m, 1000_m })
Parallel approximation by Spline.
dclspc Angle KinkToCoupled(const Track &track, Track::EndType atEnd)
dclspc Track::TrackType TrackType(const std::string &type) noexcept
Finds TrackType for string.
An interval describes the area between two numbers. It is understood to contain the near one and exlu...
Definition Interval.h:42
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
Implements a 3D - position in cartesian coordinates.
Definition Position.h:46
Implements a 2D - vector in cartesian coordinates.
Definition Vector2D.h:46
Implements a tangential space bundle.
Definition VectorBundle2.h:43
Implements a Vector bundle.
Definition VectorBundle.h:42
Implements a 3D - vector in cartesian coordinates.
Definition Vector.h:48
A dynamic object in physical space.
Definition Body.h:44
A Connector rearranges the connections between several track ends.
Definition Connector.h:226
Curves implement this interface that then can get attached to a track to define the tracks geometry.
Definition Curve.h:198
Definition Event.h:40
Type used for IDs in the trax library.
Definition IDType.h:43
Track that can get attached to a moving body.
Definition MovableTrack.h:37
Provides two values for orientation.
Definition Orientation.h:37
Track that can be the original to parallel tracks.
Definition ParallelTrack.h:35
A RoadwayTwist is used to define the actual rotating angle around the tangent at a curve to get the c...
Definition RoadwayTwist.h:81
A Sensor can get attached to a track and be triggerd when a Location runs over it.
Definition Sensor.h:71
A Signal is positioned along a track and is submitted to a Train if it runs over it.
Definition Signal.h:61
Target for signal notification.
Definition Signal.h:407
Designates two track ends. Typically used for coupling relations.
Definition Track.h:325
End theOne
First end to be coupled.
Definition Track.h:326
End theOther
Second end to be coupled.
Definition Track.h:327
Designates an end at a specific track.
Definition Track.h:303
EndType type
front or end end of the track.
Definition Track.h:318
IDType id
Identifier of the track.
Definition Track.h:317
Overlapping data.
Definition Track.h:558
IDType forID
ID that was tested for.
Definition Track.h:559
bool withNear
true if the with range's near end is overlapped.
Definition Track.h:563
bool forFar
true if the for range's far end is overlapped.
Definition Track.h:561
bool withFar
true if the with range's far end is overlapped.
Definition Track.h:564
bool forNear
true if the for range's near end is overlapped.
Definition Track.h:560
IDType withID
ID of the reservation that overlaps.
Definition Track.h:562
Interface for making and shaping tracks.
Definition Track.h:831
virtual void Flip(bool flipAttached=false)=0
Exchanges start and end of the track, but keeps geometry.
virtual std::unique_ptr< RoadwayTwist > DetachTwist()=0
Detaches the current Twist from the track.
static dclspc std::shared_ptr< TrackBuilder > Make(TrackType type=TrackType::standard) noexcept
Makes a standard Track object.
virtual void DestroyEndTransitionSignal(EndType atend)=0
Destroys the internal transition Signal.
virtual void Attach(std::pair< std::unique_ptr< const Curve >, common::Interval< Length > > &curve)=0
Attaches a Curve to the track.
virtual int CountSensors() const =0
virtual void SetFrame(const spat::Frame< Length, One > &start, Length s, bool bAllowTwistOffset=true)=0
Sets the frame so that Transition(s,start) will give start.
virtual std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > GetCurve() const noexcept=0
virtual void Couple(std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > thisEnd, std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > othersEnd)=0
Couple this track at thisend with pOtherTrack at othersend.
virtual const spat::Frame< Length, One > & GetFrame() const noexcept=0
Gets the pose of the track relative to its parent TrackCollection.
virtual void Attach(std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > curve)=0
Attaches a Curve to the track.
virtual void DeCouple(EndType thisEnd=EndType::any, bool oneSided=false)=0
Remove coupling from this end.
virtual std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > DetachCurve() noexcept=0
Detaches the Curve from the track.
virtual void Attach(std::shared_ptr< const Curve > pCurve, common::Interval< Length > curveSegment={0_m,+infinite__length})=0
Attaches a Curve to the track.
virtual void CreateEndTransitionSignal(EndType atend)=0
Creates an internal Signal at the end of the track, so that a SignalTarget receives a message if it e...
virtual const spat::Frame< Length, One > & GetAbsoluteFrame() const noexcept=0
Gets the frame relative to the Module, this track is attached to. I.e. the TrackCollection's transfor...
virtual RoadwayTwist & GetTwist() const noexcept=0
virtual void SetFrame(const spat::Frame< Length, One > &frame) noexcept=0
Sets the frame directly.
virtual std::shared_ptr< Sensor > GetSensor(int idx) const noexcept=0
virtual bool Attached(const Sensor &sensor, TrackLocation *pTrackLocation=nullptr) const =0
Gets information about an attached Sensor.
virtual void Detach(const Sensor &sensor) noexcept=0
Detaches a Sensor from the track.
Full geometrical data at a point on a track.
Definition TrackData.h:36
Interface for a track used to calculate 3D positions.
Definition Track.h:275
virtual bool IsFlat() const noexcept=0
virtual ReservationIterator EndReservations() const noexcept=0
virtual void Reserve(common::Interval< Length > range, IDType forID)=0
Reserves a parameter range on the track for a specified id.
virtual ReservationIterator BeginReservations() const noexcept=0
virtual Connector * GetConnector(EndType atend) const noexcept=0
retreives a connector (e.g. a Switch) at the respective track end.
std::tuple< IDType, common::Interval< Length > > Reservation
Reserves a parameter range on the track for a specified id.
Definition Track.h:534
virtual std::vector< Overlap > Overlaps(IDType forID) const =0
Finds overlapping areas for reservations.
virtual TrackEnd TransitionEnd(EndType thisEnd) const noexcept=0
Gives the Track coupled to this at the specified end.
virtual Length GetLength() const noexcept=0
virtual bool IsCoupled(EndType atend=EndType::any) const noexcept=0
virtual bool DoSignal(const common::Interval< Length > &range, Orientation orientation, SignalTarget &signalTarget) const =0
virtual TrackUserData * UserData() const noexcept=0
virtual void DoTrigger(const common::Interval< Length > &range, const Event &_event) const =0
virtual AnglePerLength Torsion(Length s) const =0
virtual AnglePerLength Curvature(Length s) const =0
virtual std::shared_ptr< const Body > GetBody() const noexcept=0
virtual bool IsValid() const noexcept=0
EndType
Designates one of the two ends of a track.
Definition Track.h:292
@ any
Denotes the north or south end of a Railrunner.
Definition Track.h:296
@ end
Designates the far end.
Definition Track.h:295
@ front
Designates the front end.
Definition Track.h:294
virtual std::shared_ptr< const MovableTrack > GetMovableTrack() const noexcept=0
virtual Angle GetTwistValue(Length s) const =0
virtual std::shared_ptr< const TrackBuilder > This() const noexcept=0
Gets a shared pointer to this.
virtual void TNBFrame(Length s, spat::Frame< Length, One > &frame) const =0
Receives the TNB - Frame of the curve at the location.
virtual void DeleteReservation(common::Interval< Length > inRange, IDType forID=anyID) noexcept=0
Deletes a reservation with specified ID, if it overlaps with the specified range.
virtual Signal * GetSignal(const TrackLocation &loc) const noexcept=0
Gets the first Signal in the direction given by loc.
virtual void Transition(Length s, spat::Position< Length > &pos) const =0
Gives information about the pose on the track at the specified parameter value.
virtual common::Interval< Length > Range() const noexcept=0
virtual const char * TypeName() const noexcept=0
virtual spat::Vector< One > LocalUp() const =0
Gives the Curve's idiosyncratic up direction transformed by the track's frame. Some curves maintain s...
virtual bool IsReserved(common::Interval< Length > inRange, IDType forID=anyID) const noexcept=0
Is here a reservation for the specified ID inside the range on the track?
virtual std::shared_ptr< const ParallelizableTrack > GetParallelizableTrack() const noexcept=0
virtual void UserData(TrackUserData *pData) noexcept=0
Sets a pointer to user provided data.
virtual AnglePerLength GetTwistD1(Length s) const =0
std::vector< Reservation >::const_iterator ReservationIterator
Reserves a parameter range on the track for a specified id.
Definition Track.h:535
A TrackLocation ist a location on a single track.
Definition TrackLocation.h:43
An interval on a track, referenced by an id.
Definition TrackLocation.h:132