DATAKIT SDK  V2026.4
usdw.hpp
Go to the documentation of this file.
1 #ifndef _DTK_USDW_HPP
2 #define _DTK_USDW_HPP
3 
4 #include "def/define.h"
8 #include "util/error_dtk.hpp"
9 #include "util/util_mesh_dtk.hpp"
10 
11 //! \defgroup usdw_utils USD Write Util Functions
12 //! \brief.
13 
14 namespace DtkUsd
15 {
16  class USD_Writer_Private;
17 } // namespace DtkUsd
18 
20 {
21 public:
22  // Reserved for future ascii support; output is currently always binary in .usd
24 
25  // Declares the unit of the coordinates passed to Writer: must match the actual values
26  // 0.001 = mm (default), 0.0254 = inch, 0.01 = cm, 1.0 = m
27  // This is NOT a conversion factor; the caller is responsible for consistency
28  double m_publicMetersPerUnit{ 0.001 };
29 };
30 
32 {
33 public:
34  //! \ingroup usdw_utils
35  //! \brief Constructor: initialises the writer for a USD file
36  //! \param [in] inOutputFile Path of the USD file to write (only .usd is supported)
37  //! \param [in] inOptions Optional writer configuration
38  //! \param [out] outErr dtkNoError on success
39  Dtk_UsdWriter( const Dtk_string& inOutputFile, Dtk_ErrorStatus& outErr, const WriterOptions& inOptions );
40 
41  //! \ingroup usdw_utils
42  //! \brief Reserved for future text support
43  //! \param [in] inValue Kept for API compatibility; output is currently always binary in .usd
44  void ConfigWriteAscii( Dtk_bool inValue );
45 
46  //! \ingroup usdw_utils
47  //! \brief Destructor: flushes and closes the USD file
49 
50  //! \ingroup usdw_utils
51  //! \brief Writes a mesh into the current instance node
52  //! \param [in] inMesh Mesh to write
53  //! \return dtkNoError on success
55 
56  //! \ingroup usdw_utils
57  //! \brief Opens a new Xform instance node and pushes it onto the hierarchy stack
58  //! \param [in] inInstanceName Prim name (invalid characters are replaced with '_')
59  //! \param [in] inProtoID Prototype identifier for instancing. Pass -1 to disable instancing for this node
60  //! \param [out] outIsNewInstance DTK_TRUE when the prim is created for the first time;
61  //! DTK_FALSE when a inProtoID was already registered and a reference is emitted instead —
62  //! in that case WriteMesh() calls inside this node are skipped
63  //! \param [in] inTrans Transform matrix to apply on the prim (identity by default)
64  //! \param [in] inRgb Display colour of the prim (unused by default)
65  //! \param [in] inMetaTab Optional metadata attached to the prim
66  //! \return dtkNoError on success.
67  Dtk_ErrorStatus OpenInstance( const Dtk_string& inInstanceName,
68  Dtk_Int64 inProtoID,
69  Dtk_bool& outIsNewInstance,
70  const Dtk_transfo& inTrans = Dtk_transfo(),
71  const Dtk_RGB& inRgb = Dtk_RGB(),
73 
74  //! \ingroup usdw_utils
75  //! \brief Closes the last opened instance node
76  //! Must be called once for every successful OpenInstance() call
77  //! \return dtkNoError on success
79 
80 private:
81  DtkUsd::USD_Writer_Private* _Private;
82 
83 private:
84  // Non-copyable
85  Dtk_UsdWriter( const Dtk_UsdWriter& );
86  Dtk_UsdWriter& operator=( const Dtk_UsdWriter& );
87 };
88 
89 #endif // _DTK_USDW_HPP
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Dtk_UsdWriter::OpenInstance
Dtk_ErrorStatus OpenInstance(const Dtk_string &inInstanceName, Dtk_Int64 inProtoID, Dtk_bool &outIsNewInstance, const Dtk_transfo &inTrans=Dtk_transfo(), const Dtk_RGB &inRgb=Dtk_RGB(), const Dtk_tab< Dtk_MetaDataPtr > &inMetaTab=Dtk_tab< Dtk_MetaDataPtr >())
Opens a new Xform instance node and pushes it onto the hierarchy stack.
Dtk_UsdWriter::ConfigWriteAscii
void ConfigWriteAscii(Dtk_bool inValue)
Reserved for future text support.
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
Dtk_UsdWriter::~Dtk_UsdWriter
~Dtk_UsdWriter()
Destructor: flushes and closes the USD file.
WriterOptions
Definition: usdw.hpp:20
DTK_FALSE
#define DTK_FALSE
Definition: define.h:727
Dtk_bool
char Dtk_bool
Definition: define.h:724
util_mesh_dtk.hpp
Dtk_Int64
int64_t Dtk_Int64
Definition: define.h:691
Dtk_UsdWriter::WriteMesh
Dtk_ErrorStatus WriteMesh(const Dtk_MeshPtr &inMesh)
Writes a mesh into the current instance node.
error_dtk.hpp
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
DtkUsd
Definition: usdw.hpp:15
dtk_transfo.hpp
WriterOptions::m_publicMetersPerUnit
double m_publicMetersPerUnit
Definition: usdw.hpp:28
define.h
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:84
Dtk_UsdWriter
Definition: usdw.hpp:32
Dtk_UsdWriter::Dtk_UsdWriter
Dtk_UsdWriter(const Dtk_string &inOutputFile, Dtk_ErrorStatus &outErr, const WriterOptions &inOptions)
Constructor: initialises the writer for a USD file.
Dtk_UsdWriter::CloseLastInstance
Dtk_ErrorStatus CloseLastInstance()
Closes the last opened instance node Must be called once for every successful OpenInstance() call.
dtk_string.hpp
dtk_rgb.hpp
Dtk_RGB
Definition: dtk_rgb.hpp:8
WriterOptions::m_writeAscii
Dtk_bool m_writeAscii
Definition: usdw.hpp:23