DATAKIT SDK  V2026.4
3dxmlw.hpp
Go to the documentation of this file.
1 #ifndef _3DXMLW_HPP_
2 #define _3DXMLW_HPP_
3 
4 
5 //! \brief Exported APIs for 3dxml (.3dxml) Write Library
6 namespace _3dxmlw
7 {
8  //! \class WriteParameters
9  //! \brief This class provides several parameters to tunes 3dxml Writter.\n
10  //! It must be provided to addInstance3D method.
11  //! \code
12  //! //...
13  //! \endcode
15  {
16  protected:
32  public:
33  //! \BaseConstructor
35  :_Blanked(0)
37  , _Color( Dtk_RGB() )
38  , _CurveThickness( 0 )
39  , _HasMaterial( false )
40  , _MaterialName( L"" )
41  , _MaterialAmbient( 0 )
42  , _MaterialDiffuse( 0 )
43  , _MaterialSpecular( 0 )
44  , _MaterialRefraction( 0 )
50  {
51  }
52 
53  //! \BaseDestructor
55  {
56  }
57 
58  //! \brief Sets the blanked status for the written instance node.
59  //! \param [in] inBlanked : blanked status.
60  inline void SetBlankedStatus( const Dtk_Int32 inBlanked )
61  {
62  _Blanked = inBlanked;
63  }
64  //! \brief Retrieve the Written blanked status.
65  inline Dtk_Int32 GetBlankedStatus() const
66  {
67  return _Blanked;
68  }
69  //! \brief Sets the color for the written instance node.
70  //! \param [in] inColor : color.
71  inline void SetColor( const Dtk_RGB & inColor )
72  {
73  _Color = inColor;
74  }
75  //! \brief Retrieve the Written color.
76  inline Dtk_RGB GetColor() const
77  {
78  return _Color;
79  }
80  //! \brief Sets the curve type for the written instance node.
81  //! \param [in] inCurvetype : curve type.
82  inline void SetCurveType( Dtk_FontLineType inCurveType )
83  {
84  _CurveType = inCurveType;
85  }
86  //! \brief Retrieve the Written curve type.
88  {
89  return _CurveType;
90  }
91  //! \brief Sets the curve thickness for the written instance node.
92  //! \param [in] inCurveThickness : curve thickness.
93  inline void SetCurveThickness( Dtk_Double64 inCurveThickness )
94  {
95  _CurveThickness = inCurveThickness;
96  }
97  //! \brief Retrieve the Written curve thickness.
99  {
100  return _CurveThickness;
101  }
102 
103  //! \brief Sets material parameters to be applied on the written instance node.
104  inline void SetMaterial( const Dtk_string & inMaterialName,
105  const Dtk_RGB & inAmbientColor = Dtk_RGB(),
106  const Dtk_RGB & inDiffuseColor = Dtk_RGB(),
107  const Dtk_RGB & inSpecularColor = Dtk_RGB(),
108  Dtk_Double64 inAmbient = 0,
109  Dtk_Double64 inDiffuse = 0,
110  Dtk_Double64 inSpecular = 0,
111  Dtk_Double64 inRefraction = 0,
112  Dtk_Double64 inTransparency = 0,
113  Dtk_Double64 inReflectivity = 0 )
114  {
115  _HasMaterial = true;
116  _MaterialName = inMaterialName;
117  _MaterialAmbientColor = inAmbientColor;
118  _MaterialDiffuseColor = inDiffuseColor;
119  _MaterialSpecularColor = inSpecularColor;
120  _MaterialAmbient = inAmbient;
121  _MaterialDiffuse = inDiffuse;
122  _MaterialSpecular = inSpecular;
123  _MaterialRefraction = inRefraction;
124  _MaterialTransparency = inTransparency;
125  _MaterialReflectivity = inReflectivity;
126  }
127 
128  //! \brief Clears material parameters for the written instance node.
129  inline void ClearMaterial()
130  {
131  _HasMaterial = false;
132  _MaterialName = L"";
133  }
134 
135  //! \brief Returns whether a material was actually set on this instance.
136  //! \remark Guards against a stale/garbage _HasMaterial flag: a material is only
137  //! considered present if a non-empty material name was actually provided via SetMaterial().
138  inline Dtk_bool HasMaterial() const { return _HasMaterial && !_MaterialName.is_NULL() && _MaterialName.len() > 0; }
139  inline Dtk_string GetMaterialName() const { return _MaterialName; }
149  };
150 
151  //! \class WriteOptions
152  //! \brief This class provides several options to tune 3dxml Writer.\n
153  //! It must be provided to _3dxmlw::InitWrite method.
154  //! \code
155  //! //...
156  //! Dtk_string LogFile = L"MyLogFile.log";
157  //! _3dxmlw::WriteOptions 3DxmlOptions;
158  //! Dtk_ErrorStatus err = _3dxmlw::InitWrite( LogFile, 3DxmlOptions);
159  //! //...
160  //! \endcode
162  {
163  protected:
164 
165  public:
166  //! \BaseConstructor
168 
169  //! \BaseDestructor
171 
172  };
173 
174  //! \brief Initialize the 3dxmlw Writer
175  //! \return dtkNoError if it is OK.
176  //! \param [in] inOutputFile : Output file name
177  //! \param [in] inLogFile : Log file
178  //! \param [in] inOptions : Options
179  //! \remark This function is the first call for the writer, it must me called after Dtk_API::StartAPI(...)
180  DtkErrorStatus InitWrite(const Dtk_string& inOutputFile, const Dtk_string& inLogFile, WriteOptions& inOptions);
181 
182  //! \brief Creation of the output file and free the 3dxmlw Writer
183  //! \return dtkNoError if it is OK.
184  //! \remark used as the last function used for the writer.
186 
187  //! \brief Don't create a component already viewed. Is instantiate by an instance
188  //! \param [in] inCurrentChildId : Current child id
189  //! \return DTK_TRUE if component already exist.
190  //! \remark
192 
193  //! \brief Create Reference3D node
194  //! \param [in] inName : Node Name
195  //! \param [in] inComponentId : Component id
196  //! \param [in] inMetadata : metadata
197  //! \return
198  //! \remark : add only V_description
199  void addReference3D(const Dtk_string & inName, Dtk_ID inComponentId,Dtk_tab<Dtk_MetaDataPtr> & inMetadata);
200 
201  //! \brief Create ReferenceRep node
202  //! \param [in] inMesh : Mesh Array
203  //! \param [in] inName : Node Name
204  //! \param [in] inComponentId : Component id
205  //! \return
206  //! \remark
207  void addReferenceRep(const Dtk_tab<Dtk_MeshPtr> & inMesh, const Dtk_string & inName, Dtk_Size_t inComponentId);
208 
209  //! \brief Create Instance3D node
210  //! \param [in] inParentId : Parent id
211  //! \param [in] inChildId : Child id
212  //! \param [in] inMatrix : Instance matrix
213  //! \param [in] inInstanceName : Instance Name
214  //! \param [in] inMetadata : metadata
215  //! \param [in] inParameters : parameters
216  //! \return
217  //! \remark : add only V_description
218  void addInstance3D( Dtk_ID parentId,
219  Dtk_ID ref3dId,
220  const Dtk_transfo &matrix,
221  const Dtk_string &objectName,
222  Dtk_MetaDataPtr & inMetadata,
223  const WriteParameters & inParameters = WriteParameters() );
224 }
225 
226 #endif
_3dxmlw::WriteParameters::_MaterialSpecularColor
Dtk_RGB _MaterialSpecularColor
Definition: 3dxmlw.hpp:31
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:688
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
_3dxmlw::WriteParameters::GetMaterialAmbient
Dtk_Double64 GetMaterialAmbient() const
Definition: 3dxmlw.hpp:140
_3dxmlw::WriteParameters::GetBlankedStatus
Dtk_Int32 GetBlankedStatus() const
Retrieve the Written blanked status.
Definition: 3dxmlw.hpp:65
_3dxmlw::WriteParameters::_MaterialAmbient
Dtk_Double64 _MaterialAmbient
Definition: 3dxmlw.hpp:23
_3dxmlw::WriteOptions::WriteOptions
WriteOptions()
Default constructor.
Definition: 3dxmlw.hpp:167
_3dxmlw::WriteParameters::_MaterialReflectivity
Dtk_Double64 _MaterialReflectivity
Definition: 3dxmlw.hpp:28
_3dxmlw::WriteOptions
This class provides several options to tune 3dxml Writer. It must be provided to _3dxmlw::InitWrite m...
Definition: 3dxmlw.hpp:162
_3dxmlw::WriteParameters::SetCurveThickness
void SetCurveThickness(Dtk_Double64 inCurveThickness)
Sets the curve thickness for the written instance node.
Definition: 3dxmlw.hpp:93
_3dxmlw::WriteParameters::_MaterialTransparency
Dtk_Double64 _MaterialTransparency
Definition: 3dxmlw.hpp:27
_3dxmlw::WriteParameters::GetMaterialName
Dtk_string GetMaterialName() const
Definition: 3dxmlw.hpp:139
_3dxmlw::WriteParameters::_MaterialRefraction
Dtk_Double64 _MaterialRefraction
Definition: 3dxmlw.hpp:26
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
_3dxmlw::WriteParameters::GetCurveThickness
Dtk_Double64 GetCurveThickness() const
Retrieve the Written curve thickness.
Definition: 3dxmlw.hpp:98
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:711
_3dxmlw::addInstance3D
void addInstance3D(Dtk_ID parentId, Dtk_ID ref3dId, const Dtk_transfo &matrix, const Dtk_string &objectName, Dtk_MetaDataPtr &inMetadata, const WriteParameters &inParameters=WriteParameters())
Create Instance3D node.
_3dxmlw::addReference3D
void addReference3D(const Dtk_string &inName, Dtk_ID inComponentId, Dtk_tab< Dtk_MetaDataPtr > &inMetadata)
Create Reference3D node.
Dtk_bool
char Dtk_bool
Definition: define.h:724
_3dxmlw::WriteParameters::~WriteParameters
~WriteParameters()
Destructor.
Definition: 3dxmlw.hpp:54
Dtk_Double64
double Dtk_Double64
Definition: define.h:698
_3dxmlw::WriteParameters::WriteParameters
WriteParameters()
Default constructor.
Definition: 3dxmlw.hpp:34
_3dxmlw::WriteParameters::HasMaterial
Dtk_bool HasMaterial() const
Returns whether a material was actually set on this instance.
Definition: 3dxmlw.hpp:138
_3dxmlw::WriteOptions::~WriteOptions
~WriteOptions()
Destructor.
Definition: 3dxmlw.hpp:170
_3dxmlw::WriteParameters::_MaterialAmbientColor
Dtk_RGB _MaterialAmbientColor
Definition: 3dxmlw.hpp:29
_3dxmlw::WriteParameters::_MaterialDiffuseColor
Dtk_RGB _MaterialDiffuseColor
Definition: 3dxmlw.hpp:30
_3dxmlw::WriteParameters::_MaterialDiffuse
Dtk_Double64 _MaterialDiffuse
Definition: 3dxmlw.hpp:24
_3dxmlw::WriteParameters::GetCurveType
Dtk_FontLineType GetCurveType() const
Retrieve the Written curve type.
Definition: 3dxmlw.hpp:87
_3dxmlw::WriteParameters::_HasMaterial
Dtk_bool _HasMaterial
Definition: 3dxmlw.hpp:21
_3dxmlw::WriteParameters::_CurveThickness
Dtk_Double64 _CurveThickness
Definition: 3dxmlw.hpp:20
_3dxmlw::EndWrite
DtkErrorStatus EndWrite()
Creation of the output file and free the 3dxmlw Writer
_3dxmlw::WriteParameters::_MaterialName
Dtk_string _MaterialName
Definition: 3dxmlw.hpp:22
_3dxmlw::WriteParameters::_Color
Dtk_RGB _Color
Definition: 3dxmlw.hpp:19
_3dxmlw::WriteParameters::SetColor
void SetColor(const Dtk_RGB &inColor)
Sets the color for the written instance node.
Definition: 3dxmlw.hpp:71
Dtk_Int32
int32_t Dtk_Int32
Definition: define.h:686
_3dxmlw::WriteParameters
This class provides several parameters to tunes 3dxml Writter. It must be provided to addInstance3D m...
Definition: 3dxmlw.hpp:15
_3dxmlw::WriteParameters::_CurveType
Dtk_FontLineType _CurveType
Definition: 3dxmlw.hpp:18
_3dxmlw::WriteParameters::GetMaterialDiffuseColor
Dtk_RGB GetMaterialDiffuseColor() const
Definition: 3dxmlw.hpp:147
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
_3dxmlw::WriteParameters::_MaterialSpecular
Dtk_Double64 _MaterialSpecular
Definition: 3dxmlw.hpp:25
_3dxmlw::isAlreadyAddComponent
Dtk_bool isAlreadyAddComponent(Dtk_ID inCurrentChildId)
Don't create a component already viewed. Is instantiate by an instance.
_3dxmlw::WriteParameters::GetMaterialDiffuse
Dtk_Double64 GetMaterialDiffuse() const
Definition: 3dxmlw.hpp:141
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
_3dxmlw::WriteParameters::SetMaterial
void SetMaterial(const Dtk_string &inMaterialName, const Dtk_RGB &inAmbientColor=Dtk_RGB(), const Dtk_RGB &inDiffuseColor=Dtk_RGB(), const Dtk_RGB &inSpecularColor=Dtk_RGB(), Dtk_Double64 inAmbient=0, Dtk_Double64 inDiffuse=0, Dtk_Double64 inSpecular=0, Dtk_Double64 inRefraction=0, Dtk_Double64 inTransparency=0, Dtk_Double64 inReflectivity=0)
Sets material parameters to be applied on the written instance node.
Definition: 3dxmlw.hpp:104
Dtk_string::is_NULL
Dtk_bool is_NULL() const
_3dxmlw::WriteParameters::SetBlankedStatus
void SetBlankedStatus(const Dtk_Int32 inBlanked)
Sets the blanked status for the written instance node.
Definition: 3dxmlw.hpp:60
_3dxmlw
Exported APIs for 3dxml (.3dxml) Write Library.
Definition: 3dxmlw.hpp:7
Dtk_FontLineType
Dtk_FontLineType
This is a set of line styles.
Definition: util_ent_dtk.hpp:46
DTK_NO_PATTERN
@ DTK_NO_PATTERN
Definition: util_ent_dtk.hpp:47
_3dxmlw::WriteParameters::GetMaterialTransparency
Dtk_Double64 GetMaterialTransparency() const
Definition: 3dxmlw.hpp:144
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:84
_3dxmlw::WriteParameters::GetMaterialReflectivity
Dtk_Double64 GetMaterialReflectivity() const
Definition: 3dxmlw.hpp:145
_3dxmlw::WriteParameters::GetMaterialSpecularColor
Dtk_RGB GetMaterialSpecularColor() const
Definition: 3dxmlw.hpp:148
_3dxmlw::WriteParameters::GetMaterialSpecular
Dtk_Double64 GetMaterialSpecular() const
Definition: 3dxmlw.hpp:142
_3dxmlw::WriteParameters::GetMaterialRefraction
Dtk_Double64 GetMaterialRefraction() const
Definition: 3dxmlw.hpp:143
_3dxmlw::WriteParameters::_Blanked
Dtk_Int32 _Blanked
Definition: 3dxmlw.hpp:17
_3dxmlw::InitWrite
DtkErrorStatus InitWrite(const Dtk_string &inOutputFile, const Dtk_string &inLogFile, WriteOptions &inOptions)
Initialize the 3dxmlw Writer
_3dxmlw::WriteParameters::GetColor
Dtk_RGB GetColor() const
Retrieve the Written color.
Definition: 3dxmlw.hpp:76
Dtk_string::len
int len() const
Retrieve the length of the Dtk_string.
_3dxmlw::addReferenceRep
void addReferenceRep(const Dtk_tab< Dtk_MeshPtr > &inMesh, const Dtk_string &inName, Dtk_Size_t inComponentId)
Create ReferenceRep node.
_3dxmlw::WriteParameters::GetMaterialAmbientColor
Dtk_RGB GetMaterialAmbientColor() const
Definition: 3dxmlw.hpp:146
Dtk_RGB
Definition: dtk_rgb.hpp:8
_3dxmlw::WriteParameters::SetCurveType
void SetCurveType(Dtk_FontLineType inCurveType)
Sets the curve type for the written instance node.
Definition: 3dxmlw.hpp:82
_3dxmlw::WriteParameters::ClearMaterial
void ClearMaterial()
Clears material parameters for the written instance node.
Definition: 3dxmlw.hpp:129