35 geometry->setLocalTransform( transform );
45 template<
typename ContainerT>
48 if ( container.size() < 2 )
51 agxAssert( std::is_sorted( container.begin(), container.end() ) );
54 for (
agx::UInt i = 1; i < container.size(); ++i ) {
55 if ( container[ i ] == container[ i - 1 ] +
typename ContainerT::value_type( 1 ) )
56 ++result.back().
end();
73 template<
typename ContainerT>
79 if ( result.size() == 1 && result.front().empty() )
87 for (
agx::UInt i = 0; i < result.size(); ++i ) {
88 auto& range = result[ i ];
89 const auto size = range.
size();
90 range.begin() = container[ range.begin() ];
91 range.end() = range.begin() + size;
94 if ( result.size() < 2 )
99 const auto numNodes = track.
nodes().
size();
100 if ( result.front().begin() ==
agx::UInt( 0 ) && result.back().end() == numNodes ) {
101 result.front().begin() = result.back().begin();
115 return index == 0 ? size - 1 : index - 1;
125 return ( index + 1 ) % size;
136 const auto totalNumNodes = track.
nodes().
size();
137 if ( totalNumNodes < 1 )
138 return track.
nodes();
140 const agx::UInt numNodes = signedNumNodes < 0 ?
145 if ( signedNumNodes < 0 ) {
146 beginIndex = nodeIndex > numNodes ?
147 nodeIndex - numNodes :
148 nodeIndex + totalNumNodes - numNodes;
149 endIndex = nodeIndex;
152 beginIndex = ( nodeIndex + 1 ) % totalNumNodes;
153 endIndex = ( nodeIndex + numNodes + 1 ) % totalNumNodes;
191 return trackThickness + 0.25 * trackNodeLength;
261 operator bool()
const;
375 size_t numLoops = 0 )
378 , m_numLoops( 2 * numLoops )
388 m_index1 = nextIndex( m_index1 );
389 m_index2 = nextIndex( m_index2 );
395 return { m_index1, m_index2 };
400 return this->m_index1 == other.m_index1 &&
401 this->m_index2 == other.m_index2 &&
402 this->m_numLoops == other.m_numLoops;
407 return !( ( *this ) == other );
411 inline size_t nextIndex(
size_t index )
413 m_numLoops += ( index + 1 ) == m_size;
414 return ( index + 1 ) % m_size;
432 return { 0, 1, m_size };
437 return { 0, 1, m_size, 1 };
457 template<
typename ContainerT>
464 using pair = std::pair<reference, reference>;
468 ContainerT& container,
469 size_t numLoops = 0 )
470 : m_it( index1, index2, container.size(), numLoops )
471 , m_container( container )
486 const auto [index1, index2] = *m_it;
492 return this->m_it == other.m_it;
497 return !( ( *this ) == other );
502 ContainerT& m_container;
507 : m_container( container )
513 return { 0, 1, m_container };
518 return { 0, 1, m_container, 1 };
522 ContainerT& m_container;
528 if constexpr ( std::is_integral_v<T> )
#define AGXVEHICLE_EXPORT
A box shape for geometric intersection tests.
The geometry representation used by the collision detection engine.
Utility color class with "common colors".
static agxRender::Color OrangeRed()
static agxRender::Color GreenYellow()
Segment range object for linked structure.
const agx::Vec3 & getHalfExtents() const
agx::RigidBody * getRigidBody() const
Node/segment/shoe object in agxVehicle::Track.
Object containing properties of an agxVehicle::Track.
agx::Real getNodeLength() const
agx::Real getNodeThickness() const
Wheel used in tracked vehicles.
Assembly object representing a continuous track with a given number of shoes (nodes).
Iterator getIterator(agx::UInt index) const
TrackRoute * getRoute() const
View of indices given size, e.g., for ( auto [curr, next] : OneOffCircularIndexView{ 5 } ) ....
OneOffCircularIndexView(size_t size)
View a container with current value and next at the same time.
OneOffCircularView(ContainerT &container)
static AffineMatrix4x4T< Real > translate(const Vec3T< Real > &dv)
Return a matrix which translates according to dv.
static QuatT< Real > rotate(Real angle, Real x, Real y, Real z)
Static method which constructs and returns a Quaternion from a rotation given as angle radians around...
The rigid body class, combining a geometric model and a frame of reference.
bool add(agxCollide::Geometry *geometry, const agx::AffineMatrix4x4 &localTransform, bool incrementalMassCalculation=false)
Connect a geometry to this rigid body.
AGXVEHICLE_EXPORT void setTrackStiffnessFromCompliance(TrackProperties *properties, agx::Real compliance, agx::Real nodeLength)
Set track stiffness from the deprecated compliance parameter that previously where defined per hinge ...
T nextIndex(T index, T size)
AGXVEHICLE_EXPORT bool isTrackSegment(const Track &track, const agx::RigidBody &rb)
Check if the given rb is a track segment type of body, e.g., a node or a segment sensor.
agx::Real getNodeWheelOverlapThreshold(const Track &track)
AGXVEHICLE_EXPORT Track::TrackWheelContainer getWheelsAlongTrack(const Track &track)
Finds the wheels (sorted) along the given track with the reference wheel as the first instance.
TrackNodeRange createRangeExcludingNodeIndex(const Track &track, agx::UInt nodeIndex, agx::Int signedNumNodes)
Creates a node range where nodeIndex is excluded and number of nodes to include is signed.
AGXVEHICLE_EXPORT const TrackWheel * findWheel(const Track &track, const agx::RigidBody &rb)
Finds the wheel instance in the given track if rb is a track sensor of the wheel.
IndexRangeContainer splitNonconsecutive(const ContainerT &container)
Given a sorted container this function will split the content into ranges where the elements are cons...
auto circularView(const T &foo)
void createGeometryBox(const TrackNode &node)
Default node geometry generator.
agx::AffineMatrix4x4 calculateNodeTransform(const agx::Vec3 &position, const agx::Vec3 &direction, const agx::Vec3 &wheelPlaneNormal)
Calculates the transform of a track node given position, direction (along the track) and wheel plane ...
AGXVEHICLE_EXPORT void debugRender(const WheelTangentData &tangent, const agxRender::Color &tangentColor=agxRender::Color::OrangeRed(), const agxRender::Color &upColor=agxRender::Color::GreenYellow(), agx::Real scale=1.0)
Debug render wheel tangent, including up vector.
T prevIndex(T index, T size)
agx::IndexRangeT< agx::UInt > IndexRange
agxSDK::LinkedSegmentRange< TrackNode > TrackNodeRange
Node range object for tracks.
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
Data for an external tangent between two wheels.
bool operator==(const iterator &other) const
std::pair< size_t, size_t > operator*() const
iterator(size_t index1, size_t index2, size_t size, size_t numLoops=0)
iterator & operator=(const iterator &)=delete
iterator(const iterator &)=delete
bool operator!=(const iterator &other) const
bool operator==(const iterator &other) const
iterator & operator=(const iterator &)=delete
bool operator!=(const iterator &other) const
std::pair< reference, reference > pair
iterator(size_t index1, size_t index2, ContainerT &container, size_t numLoops=0)
iterator(const iterator &)=delete
typename ContainerT::reference reference
Tan provides helpers to determine whether a point lies on the segment, defined in the given tangent s...
static bool inside(const agx::Vec3 &point, const WheelTangentData &tangent)
Check whether point lies between tangent.begin and tangent.end.
static Location findLocation(const agx::Vec3 &point, const WheelTangentData &tangent)
If the point is inside the begin - end interval, the sign relative to tangent.up decides ABOVE or BEL...
bool isOverlapping() const
Data of overlap test between a track wheel and a point.
static WheelPointOverlap test(const TrackWheel &wheel, const agx::Vec3 &point, agx::Real additionalRadius=0.0)
Perform overlap test between wheel and point.
Data of overlap test between a track wheel and a line segment.
static WheelSegmentOverlap test(const TrackWheel &wheel, const agx::Vec3 &sBegin, const agx::Vec3 &sEnd, agx::Real additionalRadius=0.0)
Test overlap of segment sBegin to sEnd vs wheel.
void render() const
Debug render overlap if overlapping, otherwise noting is rendered.
static WheelSegmentOverlap test(const TrackWheel &wheel, const WheelTangentData &tangent, agx::Real additionalRadius=0.0)
Test overlap of tangent vs wheel.