Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
TrackCollection.h
1// trax track library
2// AD 2014
3//
4// "the resolution of all the fruitless searches"
5//
6// Peter Gabriel
7//
8// Copyright (c) 2025 Trend Redaktions- und Verlagsgesellschaft mbH
9// Copyright (c) 2019 Marc-Michael Horstmann
10//
11// Permission is hereby granted to any person obtaining a copy of this software
12// and associated source code (the "Software"), to use, view, and study the
13// Software for personal or internal business purposes, subject to the following
14// conditions:
15//
16// 1. Redistribution, modification, sublicensing, or commercial use of the
17// Software is NOT permitted without prior written consent from the copyright
18// holder.
19//
20// 2. The Software is provided "AS IS", without warranty of any kind, express
21// or implied.
22//
23// 3. All copies of the Software must retain this license notice.
24//
25// For further information, please contact: horstmann.marc@trendverlag.de
26
27#pragma once
28
29#include "trax/Identified.h"
30#include "Collection.h"
31#include "CollectionDecorator.h"
32#include "trax/Track.h"
33
34#include <vector>
35
36namespace spat{
38 template<typename> struct Sphere;
39}
40
41namespace trax{
42
43 class Location;
44
46 struct TrackCollection : Collection<TrackCollection,TrackBuilder>,
47 Identified<TrackCollection>
48 {
50 static dclspc std::unique_ptr<TrackCollection> Make() noexcept;
51
52
59 virtual void SetFrame( const spat::Frame<Length,One>& frame ) noexcept = 0;
60
61
64 virtual const spat::Frame<Length,One>& GetFrame() const noexcept = 0;
65 };
66
67
74 std::vector<std::tuple<std::shared_ptr<TrackBuilder>,Track::EndType,Length>> dclspc FindTrackEnds( const TrackCollection& collection, const spat::Sphere<Length>& area, bool sort = false );
75
76
83 std::vector<std::pair<Location,Length>> dclspc FindTrackLocations( const TrackCollection& collection, const spat::Sphere<Length>& area, bool sort = false );
84
85
93 std::vector<std::pair<Location,Length>> dclspc FindTrackLocations( const TrackCollection& collection, const spat::VectorBundle<Length,One>& ray, Length gauge, bool sort = false );
94
95
103 std::pair<std::shared_ptr<TrackBuilder>,Track::EndType> dclspc Snap( const TrackCollection& collection, TrackBuilder& track, Track::EndType endType, Length maxDistance, bool bUncoupled = true );
104
105
115 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 );
116
117
124 class TrackCollectionDecorator : public CollectionDecorator<ObjectIDDecorator<Decorator<TrackCollection>>>{
125 public:
128
129
130 TrackCollectionDecorator() = delete;
131
134 TrackCollectionDecorator( std::shared_ptr<TrackCollection> pTrackCollection )
136 {}
137
138 void SetFrame( const spat::Frame<Length, One>& frame ) noexcept override{
139 return m_pComponent->SetFrame(frame);
140 }
141
142 const spat::Frame<Length, One>& GetFrame() const noexcept override{
143 return m_pComponent->GetFrame();
144 }
145 };
146}
Home of the Track and TrackBuilder interfaces.
CollectionDecorator(std::shared_ptr< InterfaceType > pComponent)
Definition CollectionDecorator.h:58
The base for decorator implementations. Needed as BaseDecorator to combine other decorator implemente...
Definition ObjectIDDecorator.h:27
std::shared_ptr< InterfaceType > m_pComponent
Definition ObjectIDDecorator.h:54
A Location specifies a position on a track system by referencing a track and a TrackLocation on it.
Definition Location.h:110
A decorator for identification part of trax objects.
Definition ObjectIDDecorator.h:90
TrackCollectionDecorator(std::shared_ptr< TrackCollection > pTrackCollection)
Constructs the decorator.
Definition TrackCollection.h:134
const spat::Frame< Length, One > & GetFrame() const noexcept override
Gets the frame of references for this TrackCollection relative to the Module.
Definition TrackCollection.h:142
void SetFrame(const spat::Frame< Length, One > &frame) noexcept override
Sets the frame of references for this TrackCollection relative to the Module.
Definition TrackCollection.h:138
TrackCollection ComponentType
Type of the decoree.
Definition TrackCollection.h:127
Value< Dimension< 0, 0, 0 > > One
Dimensionless value.
Definition DimensionedValues.h:319
Value< Dimension< 1, 0, 0 > > Length
Length.
Definition DimensionedValues.h:324
constexpr Angle pi
Circle number pi.
Definition DimensionedValues.h:1145
constexpr Real _m(Length l) noexcept
Dimensionated Values conversion functions.
Definition DimensionedValues.h:1210
Value< Dimension< 0, 0, 0 > > Angle
Angle in radians.
Definition DimensionedValues.h:320
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
STL namespace.
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
std::pair< std::shared_ptr< TrackBuilder >, Track::EndType > dclspc Snap(const TrackCollection &collection, TrackBuilder &track, Track::EndType endType, Length maxDistance, bool bUncoupled=true)
Moves a track so that one of it's ends aligns to another track end in a collection.
std::vector< std::tuple< std::shared_ptr< TrackBuilder >, Track::EndType, Length > > dclspc FindTrackEnds(const TrackCollection &collection, const spat::Sphere< Length > &area, bool sort=false)
Finds all track ends in the area.
std::vector< std::pair< Location, Length > > dclspc FindTrackLocations(const TrackCollection &collection, const spat::Sphere< Length > &area, bool sort=false)
Finds all tracks that run trough an area.
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.
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
Sphere with center and radius.
Definition Sphere.h:39
Implements a Vector bundle.
Definition VectorBundle.h:42
Interface for making and shaping tracks.
Definition Track.h:831
Collection to hold a set of Track objects.
Definition TrackCollection.h:48
static dclspc std::unique_ptr< TrackCollection > Make() noexcept
Makes a standard TrackCollection object.
virtual void SetFrame(const spat::Frame< Length, One > &frame) noexcept=0
Sets the frame of references for this TrackCollection relative to the Module.
virtual const spat::Frame< Length, One > & GetFrame() const noexcept=0
Gets the frame of references for this TrackCollection relative to the Module.
Interface for a track used to calculate 3D positions.
Definition Track.h:275