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

Interface for making and shaping tracks. More...

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

Inheritance diagram for trax::TrackBuilder:

Public Member Functions

virtual const spat::Frame< Length, One > & GetFrame () const noexcept=0
 Gets the pose of the track relative to its parent TrackCollection.
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 transformation.
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 void DeCouple (EndType thisEnd=EndType::any, bool oneSided=false)=0
 Remove coupling from this end.
virtual void Flip (bool flipAttached=false)=0
 Exchanges start and end of the track, but keeps geometry.
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 enters the track.
virtual void DestroyEndTransitionSignal (EndType atend)=0
 Destroys the internal transition Signal.
Set Frame

Sets the Frame the geometry is transformed with.

This frame can be used to move a track in space without changing its Curve geometry. It defines its position and orientation relative to the parent TrackCollection.

virtual void SetFrame (const spat::Frame< Length, One > &frame) noexcept=0
 Sets the frame directly.
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.
Attach a Curve

Sets the Curve object used by this track to define the geometry of the track.

If the curve provides a maximum length, the track's length will get truncated to it.

Parameters
pCurvePointer to the Curve object to use.
curveSegmentparameter range of the curve to use from s==0 at curveSegment.Near()
curveA piece of curve to attach. up to s == Length() at curveSegment.Far(). The curve must support this parameter range, otherwise the range gets truncated.
Exceptions
std::invalid_argumentif curve is not valid or range.Near() is infinite length.
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 Attach (std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > curve)=0
 Attaches a Curve to the track.
virtual void Attach (std::pair< std::unique_ptr< const Curve >, common::Interval< Length > > &curve)=0
 Attaches a Curve to the track.
virtual std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > DetachCurve () noexcept=0
 Detaches the Curve from the track.
virtual std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > GetCurve () const noexcept=0
Attach a Twist

Sets the RoadwayTwist object used by this track to define the up orientation of a track. If no twist is set, the default constant zero twist will be used.

virtual void Attach (std::unique_ptr< RoadwayTwist > pTwist)=0
virtual std::unique_ptr< RoadwayTwistDetachTwist ()=0
 Detaches the current Twist from the track.
virtual RoadwayTwistGetTwist () const noexcept=0
Attach a Sensor
virtual void Attach (std::shared_ptr< Sensor > pSensor, const TrackLocation &tracklocation)=0
 Attaches a Sensor at the specified location to this track. If already attached, the Sensor will be detached from its previous location.
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.
virtual std::shared_ptr< SensorGetSensor (int idx) const noexcept=0
virtual int CountSensors () const =0
Attach a Signal

Attaches a Signal to the specified range to this track.

A Signal is influencing a train while in a certain range on the track if its MovingDirection() is in start-end orientation of the TrackRange. If the TrackRange goes over the ends of this track, the signal will also get registered with the adjacent tracks, respecting the switch settings.

Parameters
pSignalPointer to Signal to be attached.
trackRangeRange the Signal should influence trains in.
TrackLocationlocation of a Signal with a zero length track range.
Exceptions
std::invalid_argumentif an invalid Signal was provided. touching this track.
virtual void Attach (std::shared_ptr< Signal > pSignal, const common::Interval< Length > &trackRange)=0
 Attaches a Signal to the specified range to this track.
virtual void Attach (std::shared_ptr< Signal > pSignal, const TrackLocation &location)=0
 Attaches a Signal to the specified location to this track.
virtual bool Attached (const Signal &signal, TrackRange *pTrackRange=nullptr) const =0
 Gets information about an attached Signal.
virtual void Detach (const Signal &signal)=0
 Detaches a Signal from the track and all adjacent tracks.
Public Member Functions inherited from trax::Track
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
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.
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.
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

Static Public Member Functions

static dclspc std::shared_ptr< TrackBuilderMake (TrackType type=TrackType::standard) noexcept
 Makes a standard Track object.

Additional Inherited Members

Public Types inherited from trax::Track
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
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.

Detailed Description

Interface for making and shaping tracks.

Member Function Documentation

◆ Attach() [1/7]

virtual void trax::TrackBuilder::Attach ( std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > curve)
pure virtual

Attaches a Curve to the track.

Implemented in trax::SectionTrack.

◆ Attach() [2/7]

virtual void trax::TrackBuilder::Attach ( std::pair< std::unique_ptr< const Curve >, common::Interval< Length > > & curve)
pure virtual

Attaches a Curve to the track.

Implemented in trax::SectionTrack.

◆ Attach() [3/7]

virtual void trax::TrackBuilder::Attach ( std::shared_ptr< const Curve > pCurve,
common::Interval< Length > curveSegment = {0_m,+infinite__length} )
pure virtual

Attaches a Curve to the track.

Implemented in trax::SectionTrack.

◆ Attach() [4/7]

virtual void trax::TrackBuilder::Attach ( std::shared_ptr< Sensor > pSensor,
const TrackLocation & tracklocation )
pure virtual

Attaches a Sensor at the specified location to this track. If already attached, the Sensor will be detached from its previous location.

Parameters
pSensorPointer to Sensor to be attached.
tracklocationParameter and orientation to attach at.

Implemented in trax::SectionTrack.

◆ Attach() [5/7]

virtual void trax::TrackBuilder::Attach ( std::shared_ptr< Signal > pSignal,
const common::Interval< Length > & trackRange )
pure virtual

Attaches a Signal to the specified range to this track.

Implemented in trax::SectionTrack.

◆ Attach() [6/7]

virtual void trax::TrackBuilder::Attach ( std::shared_ptr< Signal > pSignal,
const TrackLocation & location )
pure virtual

Attaches a Signal to the specified location to this track.

Implemented in trax::SectionTrack.

◆ Attach() [7/7]

virtual void trax::TrackBuilder::Attach ( std::unique_ptr< RoadwayTwist > pTwist)
pure virtual
Parameters
pTwistPointer to the RoadwayTwist object to use.

Implemented in trax::SectionTrack.

◆ CountSensors()

virtual int trax::TrackBuilder::CountSensors ( ) const
pure virtual
Returns
The number of sensors attached to the track.

◆ Couple()

virtual void trax::TrackBuilder::Couple ( std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > thisEnd,
std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > othersEnd )
pure virtual

Couple this track at thisend with pOtherTrack at othersend.

Couples two tracks at the specified ends together so that a Location transitions between them respectively. There is exactly one coupling per end; use Points to reconnect tracks and by that build switches. Existing connections are overriden. There is no need for the specified track ends to be adjacent in a spatial sense, but with physics engines in general trains will derail if the gap becomes too large. Be aware that tracks coupled to each other will hold cyclic strong references, so they will produce a memory leak if not uncoupled. For this reason make tracks members of a TrackSystem.

Parameters
thisEndShared pointer to this track and end of this track to be coupled. This is not derivable from this, so it has to be supplied with the function call...
othersEndtrack and end this one is to be coupled with.

◆ CreateEndTransitionSignal()

virtual void trax::TrackBuilder::CreateEndTransitionSignal ( EndType atend)
pure virtual

Creates an internal Signal at the end of the track, so that a SignalTarget receives a message if it enters the track.

Parameters
atendThe end at wich to create the Signal.

◆ DeCouple()

virtual void trax::TrackBuilder::DeCouple ( EndType thisEnd = EndType::any,
bool oneSided = false )
pure virtual

Remove coupling from this end.

Parameters
thisEndWhat track end to decouple.
oneSidedIf true only the coupling of this track to another will be removed, the other track stays connected to this.

◆ DestroyEndTransitionSignal()

virtual void trax::TrackBuilder::DestroyEndTransitionSignal ( EndType atend)
pure virtual

Destroys the internal transition Signal.

Parameters
atendThe end at wich to destroy the Signal.

◆ Detach()

virtual void trax::TrackBuilder::Detach ( const Signal & signal)
pure virtual

Detaches a Signal from the track and all adjacent tracks.

Exceptions
std::logic_errorif the Signal was not attached.

◆ DetachCurve()

virtual std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > trax::TrackBuilder::DetachCurve ( )
pure virtualnoexcept

Detaches the Curve from the track.

Returns
The curve's parameter segment and a pointer to the previous attached Curve or nullptr if none.

◆ DetachTwist()

virtual std::unique_ptr< RoadwayTwist > trax::TrackBuilder::DetachTwist ( )
pure virtual

Detaches the current Twist from the track.

There always will be a default Twist with a track. On detachment the default will be substituted. It is a constant zero twist.

Returns
A pointer to the previous active Twist.This might be the default Twist.

◆ Flip()

virtual void trax::TrackBuilder::Flip ( bool flipAttached = false)
pure virtual

Exchanges start and end of the track, but keeps geometry.

The track will run along the same path, but start and end will be swapped after this operation. The couplings get updated accordingly. The binormal direction of the track is kept if a capable twist is present; the normal direction then will flip.

Parameters
flipAttachedIf true, Sensors and Signals will keep their geometrical location along the track, thereby changing their parameter positions and orientations.

◆ GetAbsoluteFrame()

virtual const spat::Frame< Length, One > & trax::TrackBuilder::GetAbsoluteFrame ( ) const
pure virtualnoexcept

Gets the frame relative to the Module, this track is attached to. I.e. the TrackCollection's transformation.

◆ GetCurve()

virtual std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > trax::TrackBuilder::GetCurve ( ) const
pure virtualnoexcept
Returns
a pointer to the curve or nullptr if none; and the Parameter range on the curve to be mapped to the track's 0 to GetLength() range.

◆ GetSensor()

virtual std::shared_ptr< Sensor > trax::TrackBuilder::GetSensor ( int idx) const
pure virtualnoexcept
Returns
the Sensor with the specified index.

◆ GetTwist()

virtual RoadwayTwist & trax::TrackBuilder::GetTwist ( ) const
pure virtualnoexcept
Returns
A reference to the attached Twist. This might be the default Twist.

◆ SetFrame()

virtual void trax::TrackBuilder::SetFrame ( const spat::Frame< Length, One > & start,
Length s,
bool bAllowTwistOffset = true )
pure virtual

Sets the frame so that Transition(s,start) will give start.

The transformation of the track (accessed by GetFrame()) is reverse calculated in a way that the track at parameter s will return the pose that is given by start. If the twist is dynamic, a logical contradiction might occure, since the dynamic twist might not allow for a solution. If possible these cases are resolved by offsetting the twist. If not possible, a std::logic_error exception is thrown. Note that this method is computational demanding. For animations or moving several tracks at once the SetFrame( const spat::Frame<Length,One>& ) method might be better suited. If you want to animate movable tracks, consider using MovableTrack (see below) together with a Body.

Parameters
startThe frame to set the track to at s.
sThe parameter value on the track to set the frame for. The minimum valid value is 0, the maximum value is given by Length() otherwise throws an exception.
bAllowTwistOffsetAllow twist correction on contradiction.
Exceptions
std::runtime_errorif the track is not valid.
std::range_errorif s is outside the [0,Length()] range.
std::logic_errorif for geometrical reasons, the method can not work successfully.

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