14#include "SupportUSD.h"
15#include "SupportUSD_Tokens.h"
17#include "dim/support/DimSupportStream.h"
19#include "spat/VectorBundle.h"
20#include "spat/VectorBundle2.h"
21#include "spat/Frame.h"
35 USDExporter( pxr::UsdStageRefPtr stage,
const pxr::SdfPath& atPath,
bool bWriteTrackMesh =
false );
52 inline pxr::UsdStageRefPtr GetStage() const noexcept{
69 void Write(
const Curve& curve,
const std::string& pathName =
"Curve" );
70 void Write(
const Line& line,
const std::string& pathName =
"Curve" );
71 void Write(
const LineP& line,
const std::string& pathName =
"Curve" );
72 void Write(
const Arc& arc,
const std::string& pathName =
"Curve" );
73 void Write(
const ArcP& arcP,
const std::string& pathName =
"Curve" );
74 void Write(
const Helix& helix,
const std::string& pathName =
"Curve" );
75 void Write(
const HelixP& helixP,
const std::string& pathName =
"Curve" );
76 void Write(
const Cubic& cubic,
const std::string& pathName =
"Curve" );
77 void Write(
const Spline& spline,
const std::string& pathName =
"Curve" );
78 void Write(
const Clothoid&,
const std::string& pathName =
"Curve" );
79 void Write(
const Rotator&,
const std::string& pathName =
"Curve" );
85 void Write(
const LinearTwist& twist,
const std::string& pathName =
"Twist" );
92 pxr::UsdStageRefPtr m_Stage;
93 std::stack<pxr::SdfPath> m_PathStack;
94 bool m_bWriteTrackMesh;
100 m_PathStack.push( m_PathStack.top().AppendPath( pxr::SdfPath{ pathName } ) );
101 if( pxr::UsdPrim primInterval = m_Stage->DefinePrim( m_PathStack.top(), typeName ); primInterval )
110 void Write(
const spat::Position<D>& pos,
const pxr::TfToken& typeName,
const std::string& pathName )
112 m_PathStack.push( m_PathStack.top().AppendPath( pxr::SdfPath{ pathName } ) );
113 if( pxr::UsdPrim prim = m_Stage->DefinePrim( m_PathStack.top(), typeName ); prim )
123 void Write(
const spat::Vector<D>& T,
const pxr::TfToken& typeName,
const std::string& pathName )
125 m_PathStack.push( m_PathStack.top().AppendPath( pxr::SdfPath{ pathName } ) );
126 if( pxr::UsdPrim prim = m_Stage->DefinePrim( m_PathStack.top(), typeName ); prim )
135 void Write(
const spat::VectorBundle<dim::Length,dim::One>& bundle,
const pxr::TfToken& typeName,
const std::string& pathName );
136 void Write(
const spat::VectorBundle2<dim::Length,dim::One>& bundle2,
const pxr::TfToken& typeName,
const std::string& pathName );
137 void Write(
const spat::Frame<dim::Length,dim::One>& frame,
const pxr::TfToken& typeName,
const std::string& pathName );
138 void Write(
const CurveSample& curveSample,
const pxr::TfToken& typeName,
const std::string& pathName );
139 void Write(
const CubicData& cubicData,
const pxr::TfToken& typeName,
const std::string& pathName );
141 template<
typename D>
inline
142 void CreateAttribute( pxr::UsdPrim& toPrim,
const pxr::TfToken& typeName, D d ){
143 if( pxr::UsdAttribute attribute = toPrim.CreateAttribute( typeName, pxr::SdfValueTypeNames->String ); attribute )
144 attribute.Set( to_string( d ) );
147 template<
class TraxType>
148 static pxr::SdfPath Name(
const TraxType&
object,
const char* pDefault )
150 if( std::string Name =
object.Reference(
"Name" ); Name.empty() )
151 return pxr::SdfPath{ pDefault + std::to_string(
object.ID() ) };
153 return pxr::SdfPath{ pxr::SdfPath{ Name }.GetName() };
void Prepare(TrackSystem &tracksystem)
Prepare the stage for writing the track system.
void Write(const TrackSystem &tracksystem)
Write the track system to the stage.
Namespace of all the trax track libraries classes and methods.
Definition Collection.h:17
dclspc pxr::TfStaticData< UsdTraxTokenTypes > UsdTraxTokens
An interval describes the area between two numbers. It is understood to contain the near one and exlu...
Definition Interval.h:42
constexpr Valtype Near() const noexcept
Definition Interval.h:381
constexpr Valtype Far() const noexcept
Definition Interval.h:386
A Frame ("TNBFrame") describes a location in 3d space and an orientation using a right handed coordin...
Definition Frame.h:52
Valtype y
cartesian y coordinate.
Definition Position.h:50
Valtype z
cartesian z coordinate.
Definition Position.h:51
Valtype x
cartesian x coordinate.
Definition Position.h:49
Valtype dy
cartesian y component.
Definition Vector.h:52
Valtype dx
cartesian x component.
Definition Vector.h:51
Valtype dz
cartesian z component.
Definition Vector.h:53
A plane arc.
Definition Curve.h:602
A plane arc with owned parameters.
Definition Curve.h:669
Curve with linear increasing curvature. Also called 'Euler Spiral'.
Definition Curve.h:1393
Combines the effect of two twists by adding them.
Definition RoadwayTwist.h:468
Collection to hold a set of Connector objects.
Definition ConnectorCollection.h:36
A Connector rearranges the connections between several track ends.
Definition Connector.h:226
A twist that stays constant over the whole track range.
Definition RoadwayTwist.h:265
Cubic polynom curve.
Definition Curve.h:1067
Curves implement this interface that then can get attached to a track to define the tracks geometry.
Definition Curve.h:198
A twist that rotates the frame arount T in a way that B is nearest a certain direction.
Definition RoadwayTwist.h:372
A double slip switch is made from eight tracks that form a crossing with the possibility to divert th...
Definition Switch.h:527
A three dimensional spiral.
Definition Curve.h:812
A three dimensional spiral with owned parameters.
Definition Curve.h:903
A straight line.
Definition Curve.h:498
A straight line with owned parameters.
Definition Curve.h:511
A twist that varies linearly between two values.
Definition RoadwayTwist.h:290
A twist that works like a DirectionalTwist but interpolates (linearly) two neighbouring attractors ac...
Definition RoadwayTwist.h:419
A twist with values at control points and either none or linear interpolation for the points in betwe...
Definition RoadwayTwist.h:333
A series of samples of points and tangents that make up a curve.
Definition Curve.h:1744
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 series of Rotator curves that continue each other.
Definition Curve.h:1631
Curve with evenly (with respect to arc length) rotating tangent vector.
Definition Curve.h:1568
A curve given by Fi,ki,ti,si samples of a real curveT.
Definition Curve.h:1856
A profile of a track.
Definition Section.h:45
A single slip switch is made from five tracks that form a crossing with the possibility to divert the...
Definition Switch.h:439
\ brief Cubic Hermite Spline.
Definition Curve.h:1162
A Switch rearranges the connections between three track ends.
Definition Switch.h:186
A switch that is connecting one narrow end to three outgoing track ends.
Definition Switch.h:326
Interface for making and shaping tracks.
Definition Track.h:831
Collection to hold a set of Track objects.
Definition TrackCollection.h:48
A track system is the container for tracks.
Definition TrackSystem.h:56