239#include "Identified.h"
240#include "Orientation.h"
241#include "RoadwayTwist.h"
243#include "common/Interval.h"
245#include "spat/Frame.h"
246#include "spat/Vector2D.h"
247#include "spat/VectorBundle.h"
248#include "spat/VectorBundle2.h"
268 struct TrackUserData;
279 enum class TrackType :
char{
285 movable_autoconnecting,
289 virtual TrackType GetTrackType() const noexcept = 0;
299 typedef std::pair<std::shared_ptr<Track>,
EndType> TrackEnd;
300 typedef std::pair<std::shared_ptr<const Track>,
const EndType> cTrackEnd;
304 End()
noexcept =
default;
310 End(
const TrackEnd& trackEnd ) noexcept
311 :
id { trackEnd.first ? trackEnd.first->ID() :
IDType{0u} },
312 type { trackEnd.second }
315 End(
const std::pair<std::shared_ptr<TrackBuilder>,
Track::EndType>& trackEnd )
noexcept;
335 virtual std::shared_ptr<const TrackBuilder>
This() const noexcept = 0;
407 virtual
bool IsFlat() const noexcept = 0;
582 virtual void UserData( TrackUserData* pData )
noexcept = 0;
586 virtual TrackUserData*
UserData() const noexcept = 0;
596 inline
bool operator==( const
Track::End& theone, const
Track::End& theother ) noexcept;
600 inline
bool operator!=( const
Track::End& theone, const
Track::End& theother ) noexcept;
604 inline
bool operator==( const
Track::Coupling& theone, const
Track::Coupling& theother ) noexcept;
608 inline
bool operator!=( const
Track::Coupling& theone, const
Track::Coupling& theother ) noexcept;
611 inline
bool operator==( const
Track::Overlap& a, const
Track::Overlap& b ) noexcept;
613 inline
bool operator<( const
Track::Overlap& a, const
Track::Overlap& b ) noexcept;
833 static dclspc std::shared_ptr<TrackBuilder>
Make( TrackType type = TrackType::standard )
noexcept;
1029 virtual
void Flip(
bool flipAttached = false ) = 0;
1088 const spat::Vector<One>& up =
Up,
1089 Length e_length = epsilon__length,
Angle e_angle = epsilon__angle );
1104 const spat::Vector<One>& up =
Up,
Length e_length = epsilon__length,
Angle e_angle = epsilon__angle );
1112 const spat::Vector<One>& up =
Up,
Length e_length = epsilon__length,
Angle e_angle = epsilon__angle );
1127 const spat::Vector<One>& up =
Up,
Length e_length = epsilon__length,
Angle e_angle = epsilon__angle );
1135 const spat::Vector<One>& up =
Up,
Length e_length = epsilon__length,
Angle e_angle = epsilon__angle );
1234 std::vector<std::shared_ptr<TrackBuilder>> dclspc SplitTrack(
const TrackBuilder& track,
int numPieces = 2,
bool cloneCurve =
false );
1238 std::vector<std::shared_ptr<TrackBuilder>> dclspc SplitTrack(
const TrackBuilder& track,
Length atParameter,
bool cloneCurve =
false );
1252 std::vector<std::shared_ptr<TrackBuilder>> dclspc
CloseGap(
1257 Length e_length = epsilon__length,
1258 Angle e_angle = epsilon__angle,
1259 bool cloneCurve =
false );
1321 bool bShiftRelativeToTwistOrUp =
true,
1323 Length maxDeviationLength = epsilon__length,
1324 Angle maxDeviationAngle = epsilon__angle );
1331 bool bShiftRelativeToTwistOrUp =
true,
1333 Length maxDeviationLength = epsilon__length,
1341 bool bShiftRelativeToTwistOrUp =
true,
1343 Length maxDeviationLength = epsilon__length,
1344 Angle maxDeviationAngle = epsilon__angle,
1352 bool bShiftRelativeToTwistOrUp,
1354 Length maxDeviationLength = epsilon__length,
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 }
1367 return theone.id == theother.id && theone.type == theother.type;
1375 return a.theOne == b.theOne &&
1376 a.theOther == b.theOther;
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;
1392inline bool operator<(
const Track::Overlap& a,
const Track::Overlap& b )
noexcept{
1393 if( a.forID < b.forID )
1395 if( a.forID == b.forID ){
1396 if( a.withID < b.withID )
1398 if( a.withID == b.withID ){
1399 if( a.forNear < b.forNear )
1401 if( a.forNear == b.forNear ){
1402 if( a.forFar < b.forFar )
1404 if( a.forFar == b.forFar ){
1405 if( a.withNear < b.withNear )
1407 if( a.withNear == b.withNear )
1408 if( a.withFar < b.withFar )
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 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
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 ©Track, 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
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