Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
trax::Track Struct Referenceabstract

Interface for a track used to calculate 3D positions. More...

#include <C:/Trend/Development/Trax3/Code/trax/Track.h>

Inheritance diagram for trax::Track:

Classes

struct  End
 Designates an end at a specific track. More...
struct  Coupling
 Designates two track ends. Typically used for coupling relations. More...
struct  Overlap
 Overlapping data. More...

Public Types

enum class  TrackType : char {
  unknown = -1 , none = 0 , standard , withGeoms ,
  movable , movable_autoconnecting , parallel
}
enum class  EndType : char { none = -1 , front = 0 , end = 1 , any }
 Designates one of the two ends of a track. More...
typedef std::pair< std::shared_ptr< Track >, EndTypeTrackEnd
typedef std::pair< std::shared_ptr< const Track >, const EndTypecTrackEnd

Public Member Functions

virtual const char * TypeName () const noexcept=0
virtual TrackType GetTrackType () const noexcept=0
virtual std::shared_ptr< const BodyGetBody () const noexcept=0
virtual bool IsValid () const noexcept=0
virtual Length GetLength () const noexcept=0
virtual common::Interval< LengthRange () const noexcept=0
virtual bool IsCoupled (EndType atend=EndType::any) const noexcept=0
virtual AnglePerLength Curvature (Length s) const =0
virtual AnglePerLength Torsion (Length s) const =0
virtual Angle GetTwistValue (Length s) const =0
virtual AnglePerLength GetTwistD1 (Length s) const =0
virtual bool IsFlat () const noexcept=0
virtual spat::Vector< OneLocalUp () const =0
 Gives the Curve's idiosyncratic up direction transformed by the track's frame. Some curves maintain some idea about where they have their upside, either because of their form (e.g Helix) or because it is extra defined (e.g. for Line). Some curves maintain no such notion (e.g. Cubic).
virtual void TNBFrame (Length s, spat::Frame< Length, One > &frame) const =0
 Receives the TNB - Frame of the curve at the location.
virtual TrackEnd TransitionEnd (EndType thisEnd) const noexcept=0
 Gives the Track coupled to this at the specified end.
virtual void DoTrigger (const common::Interval< Length > &range, const Event &_event) const =0
virtual bool DoSignal (const common::Interval< Length > &range, Orientation orientation, SignalTarget &signalTarget) const =0
virtual SignalGetSignal (const TrackLocation &loc) const noexcept=0
 Gets the first Signal in the direction given by loc.
virtual ConnectorGetConnector (EndType atend) const noexcept=0
 retreives a connector (e.g. a Switch) at the respective track end.
virtual ConnectorGetConnector (const Orientation &inDirection) const noexcept=0
 retrieves the next connector (e.g. a Switch) that can be found in the given direction.
virtual void UserData (TrackUserData *pData) noexcept=0
 Sets a pointer to user provided data.
virtual TrackUserData * UserData () const noexcept=0
virtual std::shared_ptr< const TrackBuilderThis () const noexcept=0
 Gets a shared pointer to this.
virtual std::shared_ptr< TrackBuilderThis () noexcept=0
virtual std::shared_ptr< const MovableTrackGetMovableTrack () const noexcept=0
virtual std::shared_ptr< MovableTrackGetMovableTrack () noexcept=0
virtual std::shared_ptr< const ParallelizableTrackGetParallelizableTrack () const noexcept=0
virtual std::shared_ptr< ParallelizableTrackGetParallelizableTrack () noexcept=0
Transition to Space

Gives geometrical data for a specific location along the track.

The coordinates are relative to the global frame and take into accout all the Frame offset and the twist of the track.

Parameters
sLength along the track counted from front to get the spatial data for. The minimum valid value is 0, the maximum value is given by Length() otherwise throws an error.
posPosition on the track at s.
tanTangent along the track at s.
bundlePosition and vectors along the track at s.
frameTNB - frame along the track at s.
tdThe full track data set in engine units. Used internally by trackjoints and trackfeeders.
Exceptions
std::logic_errorif no proper curve is attached with the track.
std::range_errorif s is outside the [0,Length()] range.
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 void Transition (Length s, spat::Vector< One > &tan) const =0
 Gives information about the pose on the track at the specified parameter value.
virtual void Transition (Length s, spat::VectorBundle< Length, One > &bundle) const =0
 Gives information about the pose on the track at the specified parameter value.
virtual void Transition (Length s, spat::VectorBundle2< Length, One > &bundle) const =0
 Gives information about the pose on the track at the specified parameter value.
virtual void Transition (Length s, spat::Frame< Length, One > &frame) const =0
 Gives information about the pose on the track at the specified parameter value.
virtual void Transition (Length s, TrackData< Real > &td, Real engine_meters_per_unit) const =0
 Gives information about the pose on the track at the specified parameter value.
Public Member Functions inherited from trax::Identified< Track >
virtual const std::string & Reference (const std::string &name) const=0
 Gets a reference that was set for this object by name.
virtual const std::vector< char const * > & ReferenceNames (const std::string &namePart) const=0
 Searches for all reference names that countain namePart as substring in the name.
virtual IDType ID () const noexcept=0
 Identified (const Identified &)=delete
Identified & operator= (const Identified &)=delete

Reservation mechanism

Reservations are areas on a track that are marked as reserved for some id. They allow to detemine overlappings between different reservations, distinguished by IDs.

A reservation interval's near value will be considered inside the reservation, the far value as being outside.

using Reservation = std::tuple<IDType,common::Interval<Length>>
 Reserves a parameter range on the track for a specified id.
using ReservationIterator = std::vector<Reservation>::const_iterator
 Reserves a parameter range on the track for a specified id.
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 ReservationIterator EndReservations () const noexcept=0
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 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::vector< OverlapOverlaps (IDType forID) const =0
 Finds overlapping areas for reservations.

Detailed Description

Interface for a track used to calculate 3D positions.

Trains use this kind of interfaces to calculate their positions in 3D

Member Typedef Documentation

◆ Reservation

Reserves a parameter range on the track for a specified id.

If the range is outside the track's parameter range, the reservation request will be forwarded to the connected tracks according to the active connections, as determined by switches.

Parameters
rangeThe range to reserve in parameter space. A zero range will count as no reservation at all; the reservations carry direction according to their normalized state. A range completely outside the track will throw an exception.
forIDAn idintifier to be stored with the reservation. If the reservations are used for trains, the IDs of trains or Railrunners in a collection would make a good candidate for the IDs of reservations.
Exceptions
std::range_errorIf the range lays completely outside the track.

◆ ReservationIterator

using trax::Track::ReservationIterator = std::vector<Reservation>::const_iterator

Reserves a parameter range on the track for a specified id.

If the range is outside the track's parameter range, the reservation request will be forwarded to the connected tracks according to the active connections, as determined by switches.

Parameters
rangeThe range to reserve in parameter space. A zero range will count as no reservation at all; the reservations carry direction according to their normalized state. A range completely outside the track will throw an exception.
forIDAn idintifier to be stored with the reservation. If the reservations are used for trains, the IDs of trains or Railrunners in a collection would make a good candidate for the IDs of reservations.
Exceptions
std::range_errorIf the range lays completely outside the track.

Member Enumeration Documentation

◆ EndType

enum class trax::Track::EndType : char
strong

Designates one of the two ends of a track.

Enumerator
front 

Designates the front end.

end 

Designates the far end.

any 

Denotes the north or south end of a Railrunner.

Member Function Documentation

◆ BeginReservations()

virtual ReservationIterator trax::Track::BeginReservations ( ) const
pure virtualnoexcept
Returns
begin iterator to the reservations on the track.

◆ Curvature()

virtual AnglePerLength trax::Track::Curvature ( Length s) const
pure virtual
Parameters
sParameter value 0 <= s <= Length()
Returns
The geometrical curvature at parameter value s.
Exceptions
std::logic_errorif no proper curve is attached with the track.
std::range_errorif s is outside the [0,Length()] range.

◆ DeleteReservation()

virtual void trax::Track::DeleteReservation ( common::Interval< Length > inRange,
IDType forID = anyID )
pure virtualnoexcept

Deletes a reservation with specified ID, if it overlaps with the specified range.

If the reservation transitions the track boundaries, the request will be forewarded to the connected tracks for that reservation. If a reservation overlaps inRange, it is deleted completely (not only the intersectional part).

Parameters
inRangeRange to test for.
forIDID to delete a reservation for. If it is anyID all reservations in range will get deleted.

◆ DoSignal()

virtual bool trax::Track::DoSignal ( const common::Interval< Length > & range,
Orientation orientation,
SignalTarget & signalTarget ) const
pure virtual

Receives the notifications in the range along the track.

Parameters
rangeon the track to receive the notifications for.
orientationDirection along the track to receive the signals for.
signalTargetTarget to receive the notifications.
Returns
true if the movement along the track should get calculated, false if this is supposed to stop, because the train was relocated by the Notify function.

◆ DoTrigger()

virtual void trax::Track::DoTrigger ( const common::Interval< Length > & range,
const Event & _event ) const
pure virtual

Triggers all sensors in the range in the order of their positioning along the track according to start and end of the range.

Only the sensors wich are parallel to the range orientation get triggered. Wether the sensor actually sends a pulse will depend from the match between the Event settings and the Effect filter of the sensor.

Parameters
rangeTrackrange to trigger contacts in.
_eventAn Event to match with the sensor's filter settings.

◆ EndReservations()

virtual ReservationIterator trax::Track::EndReservations ( ) const
pure virtualnoexcept
Returns
end iterator to the reservations on the track.

◆ GetBody()

virtual std::shared_ptr< const Body > trax::Track::GetBody ( ) const
pure virtualnoexcept
Returns
Returns the body a track is assigned to or nullptr.

Implemented in trax::MovableTrack.

◆ GetConnector() [1/2]

virtual Connector * trax::Track::GetConnector ( const Orientation & inDirection) const
pure virtualnoexcept

retrieves the next connector (e.g. a Switch) that can be found in the given direction.

Parameters
inDirectiondirection relative to this track to search for a Connector.
Returns
A pointer to a Connector or nullptr if none could be found.

◆ GetConnector() [2/2]

virtual Connector * trax::Track::GetConnector ( EndType atend) const
pure virtualnoexcept

retreives a connector (e.g. a Switch) at the respective track end.

Returns
A pointer to the connector or nullptr if none is present.

◆ GetLength()

virtual Length trax::Track::GetLength ( ) const
pure virtualnoexcept
Returns
the maximum valid parameter value of the track.

◆ GetMovableTrack() [1/2]

virtual std::shared_ptr< const MovableTrack > trax::Track::GetMovableTrack ( ) const
pure virtualnoexcept
Returns
A shared pointer to the movable track interface or nullptr, if none.

◆ GetMovableTrack() [2/2]

virtual std::shared_ptr< MovableTrack > trax::Track::GetMovableTrack ( )
pure virtualnoexcept
Returns
A shared pointer to the movable track interface or nullptr, if none.

◆ GetParallelizableTrack() [1/2]

virtual std::shared_ptr< const ParallelizableTrack > trax::Track::GetParallelizableTrack ( ) const
pure virtualnoexcept
Returns
A shared pointer to the parallel track interface or nullptr, if none.

◆ GetParallelizableTrack() [2/2]

virtual std::shared_ptr< ParallelizableTrack > trax::Track::GetParallelizableTrack ( )
pure virtualnoexcept
Returns
A shared pointer to the parallel track interface or nullptr, if none.

◆ GetSignal()

virtual Signal * trax::Track::GetSignal ( const TrackLocation & loc) const
pure virtualnoexcept

Gets the first Signal in the direction given by loc.

This transitions track borders.

Parameters
locThe point from wich to search and the direction in wich to search.
Returns
A pointer to a Signal if found, nullptr otherwise.

◆ GetTwistD1()

virtual AnglePerLength trax::Track::GetTwistD1 ( Length s) const
pure virtual
Returns
The first derivative of the twist function at s that gets applied by the attached RoadwayTwist.

◆ GetTwistValue()

virtual Angle trax::Track::GetTwistValue ( Length s) const
pure virtual
Returns
The twist value at s that gets applied by the attached RoadwayTwist.

◆ IsCoupled()

virtual bool trax::Track::IsCoupled ( EndType atend = EndType::any) const
pure virtualnoexcept
Returns
true if the respective end is coupled to another track end.

◆ IsFlat()

virtual bool trax::Track::IsFlat ( ) const
pure virtualnoexcept
Returns
true if it is guaranteed, that Torsion() will return 0_1Im for every s.

◆ IsValid()

virtual bool trax::Track::IsValid ( ) const
pure virtualnoexcept

Tests wether a valid curve and twist are attached.

Returns
true if the track is able to deliver valid geometry.

◆ LocalUp()

virtual spat::Vector< One > trax::Track::LocalUp ( ) const
pure virtual

Gives the Curve's idiosyncratic up direction transformed by the track's frame. Some curves maintain some idea about where they have their upside, either because of their form (e.g Helix) or because it is extra defined (e.g. for Line). Some curves maintain no such notion (e.g. Cubic).

Exceptions
std::runtime_errorif the Curve has no notion of up.
Returns
The Curve's up direction.

◆ Overlaps()

virtual std::vector< Overlap > trax::Track::Overlaps ( IDType forID) const
pure virtual

Finds overlapping areas for reservations.

A reservation for forID has to exist on the track, otherwise the result would always be an empty vector. The method will not self-overlap any reservation, but will deliver overlaps for different reservations even with the same id.

Exceptions
std::exceptionif the overlaps could not get collected.

◆ Range()

virtual common::Interval< Length > trax::Track::Range ( ) const
pure virtualnoexcept
Returns
the track's parameter range [0,Length()]

The range includes the last point of the interval.

◆ Reserve()

virtual void trax::Track::Reserve ( common::Interval< Length > range,
IDType forID )
pure virtual

Reserves a parameter range on the track for a specified id.

If the range is outside the track's parameter range, the reservation request will be forwarded to the connected tracks according to the active connections, as determined by switches.

Parameters
rangeThe range to reserve in parameter space. A zero range will count as no reservation at all; the reservations carry direction according to their normalized state. A range completely outside the track will throw an exception.
forIDAn idintifier to be stored with the reservation. If the reservations are used for trains, the IDs of trains or Railrunners in a collection would make a good candidate for the IDs of reservations.
Exceptions
std::range_errorIf the range lays completely outside the track.

◆ This() [1/2]

virtual std::shared_ptr< const TrackBuilder > trax::Track::This ( ) const
pure virtualnoexcept

Gets a shared pointer to this.

Returns
A shared const pointer to the track interface.

◆ This() [2/2]

virtual std::shared_ptr< TrackBuilder > trax::Track::This ( )
pure virtualnoexcept
Returns
A shared pointer to the track interface.

◆ TNBFrame()

virtual void trax::Track::TNBFrame ( Length s,
spat::Frame< Length, One > & frame ) const
pure virtual

Receives the TNB - Frame of the curve at the location.

The Frame received by the Transition() methods is aligned to Locations orientation on the tracks and a twisting of the line. For dynamic calculations the real geometry of the curve is needed.

Exceptions
std::logic_errorif no proper curve is attached with the track.
std::range_errorif s is outside the [0,Length()] range.

◆ Torsion()

virtual AnglePerLength trax::Track::Torsion ( Length s) const
pure virtual
Parameters
sParameter value 0 <= s <= Length()
Returns
The geometrical torsion including the first derivative of the twist (making up the total geometrical torsion) at parameter value s.
Exceptions
std::logic_errorif no proper curve is attached with trhe track.
std::range_errorif s is outside the [0,Length()] range.

◆ TransitionEnd()

virtual TrackEnd trax::Track::TransitionEnd ( EndType thisEnd) const
pure virtualnoexcept

Gives the Track coupled to this at the specified end.

Parameters
thisEndEnd of this track to get the coupled track for.
Returns
A shared pointer to the coupled track or a nullptr if no track is connected. If not nullptr, othersend will receive the type of end of the other track the coupling is existing for.

◆ TypeName()

virtual const char * trax::Track::TypeName ( ) const
pure virtualnoexcept
Returns
the name for the object type that implements this interface.

◆ UserData() [1/2]

virtual TrackUserData * trax::Track::UserData ( ) const
pure virtualnoexcept
Returns
User provided data.

◆ UserData() [2/2]

virtual void trax::Track::UserData ( TrackUserData * pData)
pure virtualnoexcept

Sets a pointer to user provided data.

Define TrackUserData to specify your data types.


The documentation for this struct was generated from the following file:
  • C:/Trend/Development/Trax3/Code/trax/Track.h