DATAKIT SDK  V2026.4
testlibcatiav5write.cpp File Reference

Functions

Dtk_ErrorStatus CatiaV5WriteSample (const Dtk_string &inResultDirectory, const Dtk_string &inInputFilesDirectory)
 
Dtk_ErrorStatus ProcessAsm (const Dtk_string &inResultDirectory, const Dtk_string &inInputFilesDirectory)
 Writes a CATProduct assembly: one sub-product referencing a CATPart and one instanced directly from an existing V5 file. More...
 
Dtk_ErrorStatus ProcessPart (const Dtk_string &inOutputFile, const Dtk_string &inReferenceName)
 
std::wstring resolvePath (const std::wstring &inRelativePath)
 
Dtk_ErrorStatus WriteBodyMaterial (const Dtk_InfoPtr &inNodeInfo)
 
Dtk_ErrorStatus WriteLayerData ()
 

Function Documentation

◆ CatiaV5WriteSample()

Dtk_ErrorStatus CatiaV5WriteSample ( const Dtk_string &  inResultDirectory,
const Dtk_string &  inInputFilesDirectory 
)
522 {
523  // First we initialize writing with name of files and protection fonction
524  //First you have to initialize the CATIA V5 writer
525  Dtk_string outputDirectory;
526 
527  std::cout << std::endl << "----------------------------------------------" << std::endl;
528  std::cout << "CatiaV5 Write start" << std::endl;
529 
530  // Choosing output directory and file name
531  outputDirectory = inResultDirectory + L"CatiaV5/";
532  outputDirectory.FixPathSeparator();
533  outputDirectory.mkdir();
534 
535  catiav5w::WriteOptions options;
536  Dtk_ErrorStatus errorStatus = options.SetFileRelease( 20 );
537  if( errorStatus != dtkNoError )
538  {
539  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
540  return errorStatus;
541  }
542 
543  errorStatus = catiav5w::InitWrite( outputDirectory + L"V5W_LogFile.log", NULL, options );
544  if( errorStatus != dtkNoError )
545  {
546  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
547  return errorStatus;
548  }
549 
550  ProcessAsm( inResultDirectory, inInputFilesDirectory );
551 
552  //...and the Main writter
554 
555  return dtkNoError;
556 }

◆ ProcessAsm()

Dtk_ErrorStatus ProcessAsm ( const Dtk_string &  inResultDirectory,
const Dtk_string &  inInputFilesDirectory 
)

Writes a CATProduct assembly: one sub-product referencing a CATPart and one instanced directly from an existing V5 file.

381 {
382  Dtk_string outputDirectory;
383  outputDirectory = inResultDirectory + "CatiaV5/";
384  outputDirectory.FixPathSeparator();
385 
386  Dtk_string CATPartFileName = outputDirectory + L"V5_sample.CATPart";
387  Dtk_string SubProductFileName = outputDirectory + L"SubProduct.CATProduct";
388  Dtk_string RootProductFileName = outputDirectory + L"RootProduct.CATProduct";
389 
390  Dtk_string V5FileName = inInputFilesDirectory + L"CatiaV5/9.CATPart";
391  //
392  //Catia V5 does not support the paths L"../Input Files/Models/"
393  std::wstring tempDirectoryFixed = resolvePath( inInputFilesDirectory.w_str() );
394  Dtk_string outputDirectoryFixed = tempDirectoryFixed.c_str();
395 
396  outputDirectoryFixed.replace( L'\\', L'/' );
397  Dtk_string CGRFileName = outputDirectoryFixed + L"CGR/Engine.cgr";
398  Dtk_string V4ModelFileName = outputDirectoryFixed + L"CatiaV4/EngineComponent.model";
399 
400  CATPartFileName.FixPathSeparator();
401  V5FileName.FixPathSeparator();
402  CGRFileName.FixPathSeparator();
403  V4ModelFileName.FixPathSeparator();
404  SubProductFileName.FixPathSeparator();
405  RootProductFileName.FixPathSeparator();
406 
407  Dtk_transfo TransformationMatrix;
408 
409  Dtk_ErrorStatus errorStatus;
410 
411  //The ProcessPart is an user implemented function to create a part
412  errorStatus = ProcessPart( CATPartFileName, L"testPart" );
413 
414  //Reference creation to external files - V4 / CGR / existing v5 file -
415  Dtk_ID PartID, V5ID, V4ID, CgrID;
416  {
417  //We create Document References to the CATPart file we create
418  errorStatus = catiav5w::CreatePartDocId( CATPartFileName, L"PartFile", PartID );
419 
420  // to an existing CATPart file
421  errorStatus = catiav5w::CreatePartDocId( V5FileName, L"V5File", V5ID );
422 
423  //...and to a CGR file
424  errorStatus = catiav5w::CreateCGRDocId( CGRFileName, "CGRFile", CgrID );
425 
426  //...and finally to a CATIA V4 '.model' file
427  errorStatus = catiav5w::CreateV4ModelDocId( V4ModelFileName, "V4File", V4ID );
428  }
429 
430  //We create the SubProduct
431  Dtk_ID SubProductID, VirtualSubComponent1ID, VirtualSubComponent2ID, PartInstanceID, VirtualSubComponent1_Instance1ID;
432  Dtk_ID PartInstanceID2, CGRInstanceID, V4InstanceID, V5InstanceID, VirtualComponent1_Instance1ID;
433  {
434  //we init a CATProduct context...
435  errorStatus = catiav5w::InitProduct( SubProductFileName, "SubProduct" );
436 
437  //we start a virtual component prototype
438  errorStatus = catiav5w::InitVirtualComponent( "VirtualSubComponent1" );
439  TransformationMatrix.setOrigin( 0, 0, 150 );
440  errorStatus = catiav5w::AddInstance( PartID, L"PartInstance", TransformationMatrix, PartInstanceID );
441  //we end the virtual component prototype
442  errorStatus = catiav5w::EndVirtualComponent( VirtualSubComponent1ID );
443 
444  //we start another virtual component prototype
445  errorStatus = catiav5w::InitVirtualComponent( "VirtualComponent1" );
446  //we add the sub component instance...
447  TransformationMatrix.setOrigin( 0.0, 0.0, 0.0 );
448  errorStatus = catiav5w::AddVirtualComponentInstance( VirtualSubComponent1ID, L"VirtualSubComponent1_Instance1", TransformationMatrix, VirtualSubComponent1_Instance1ID );
449  //we close the virtual component prototype
450  errorStatus = catiav5w::EndVirtualComponent( VirtualSubComponent2ID );
451 
452  //we insert the created Part instance...
453  TransformationMatrix.setOrigin( 0.0, 0.0, 0.0 );
454  errorStatus = catiav5w::AddInstance( PartID, L"PartInstance", TransformationMatrix, PartInstanceID2 );
455  //...a CGR instance
456  TransformationMatrix.setOrigin( 0.0, 500.0, 0.0 );
457  errorStatus = catiav5w::AddInstance( CgrID, L"CGRInstance", TransformationMatrix, CGRInstanceID );
458  //...and a V4 instance
459  TransformationMatrix.setOrigin( 0.0, -500.0, 0.0 );
460  errorStatus = catiav5w::AddInstance( V4ID, L"V4Instance", TransformationMatrix, V4InstanceID );
461  //...and an existing V5 instance
462  TransformationMatrix.setOrigin( 0.0, -1000.0, 0.0 );
463  errorStatus = catiav5w::AddInstance( V5ID, L"V5Instance", TransformationMatrix, V5InstanceID );
464  //...and the main component instance
465  TransformationMatrix.setOrigin( 0.0, 1000.0, 0.0 );
466  errorStatus = catiav5w::AddVirtualComponentInstance( VirtualSubComponent2ID, L"VirtualComponent1_Instance1", TransformationMatrix, VirtualComponent1_Instance1ID );
467 
468  //we close the CATProduct context and retrieve the resulting DocID
469  errorStatus = catiav5w::EndProduct( SubProductID );
470  }
471 
472  //Now we create the RootProduct
473  Dtk_ID RootProductID, PartInstance2ID, SubProductInstance1ID, SubProductInstance2ID;
474  {
475  //we create another CATProduct context
476  errorStatus = catiav5w::InitProduct( RootProductFileName, "RootProduct" );
477  //and we insert another time the a part instance - multinstancing management -
478  TransformationMatrix.setOrigin( 0.0, 0.0, 50.0 );
479  errorStatus = catiav5w::AddInstance( PartID, L"PartInstance2", TransformationMatrix, PartInstance2ID );
480 
481  //and two instances to the first CATProduct file
482  TransformationMatrix.setOrigin( 1000.0, 0.0, 0.0 );
483  errorStatus = catiav5w::AddInstance( SubProductID, L"SubProductInstance1", TransformationMatrix, SubProductInstance1ID );
484  TransformationMatrix.setOrigin( -1000.0, 0.0, 0.0 );
485 
486  errorStatus = catiav5w::AddInstance( SubProductID, L"SubProductInstance2", TransformationMatrix, SubProductInstance2ID );
487 
488  //Now we create an instance PathID to handle override
489  //We want to override SubProductInstance2/VirtualComponent1_Instance1/VirtualSubComponent1_Instance1/PartInstance
490  {
491  catiav5w::PathID Path1;
492  Path1.push_back( SubProductInstance2ID );
493  Path1.push_back( VirtualComponent1_Instance1ID );
494  Path1.push_back( VirtualSubComponent1_Instance1ID );
495  Path1.push_back( PartInstanceID );
496 
497  //We override Blanked status and color
499  catiav5w::OverrideInstanceColorWithPathID( Path1, Dtk_RGB( 0, 0, 255 ) );
500  }
501 
502  ////No we want to override SubProductInstance1/CGRInstance
503  {
504  catiav5w::PathID Path2;
505  Path2.push_back( SubProductInstance1ID );
506  Path2.push_back( CGRInstanceID );
507 
508  //We override Color and Alpha
509  catiav5w::OverrideInstanceColorWithPathID( Path2, Dtk_RGB( 0, 255, 255 ) );
511  }
512  //finally we close the second CATProduct...
513  errorStatus = catiav5w::EndProduct( RootProductID );
514  }
515 
516  std::cout << "=> " << RootProductFileName.c_str() << std::endl << "CatiaV5 Write end" << std::endl;
517  return errorStatus;
518 }

◆ ProcessPart()

Dtk_ErrorStatus ProcessPart ( const Dtk_string &  inOutputFile,
const Dtk_string &  inReferenceName 
)
91 {
92  Dtk_ErrorStatus errorStatus;
93  // We construct a body with a solid
95 
96  // We construct a body with an Open Shell
97  Dtk_BodyPtr body_openshell = sampleWriter::CreateOpenShell();
98 
99  // We construct a body with Wireframe
100  Dtk_BodyPtr body_wireframe = sampleWriter::CreateCurves();
101 
102  // We construct a body with a Point
103  Dtk_BodyPtr body_point = sampleWriter::CreatePoint();
104 
105  // We construct a body with an Infinite Plane
107 
108  // We construct a body with an Infinite Line / Axis
110 
111  // We construct a mesh
113 
114  Dtk_UUID PartUUID;
115  //You init the Part writer
116  errorStatus = catiav5w::InitPart( inOutputFile, inReferenceName, PartUUID );
117  if( errorStatus != dtkNoError )
118  {
119  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
120  return errorStatus;
121  }
122 
123 
124  // We create a new group of entities with a name (you must create at least one group)
125  // This sample make a surfacic group use to construct a solid
126  Dtk_InfoPtr MyCurveSetInfo = Dtk_Info::Create();
127  MyCurveSetInfo->SetName( L"MyCurveSet" );
128  errorStatus = catiav5w::CreateNode( catiav5w::NodeTypeGeometricSet, MyCurveSetInfo );
129  if( errorStatus != dtkNoError )
130  {
131  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
132  return errorStatus;
133  }
134 
135  ////Writing Wire entities
136  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( body_wireframe ) );
137  if( errorStatus != dtkNoError )
138  {
139  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
140  return errorStatus;
141  }
142 
143  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( body_point ) );
144  if( errorStatus != dtkNoError )
145  {
146  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
147  return errorStatus;
148  }
149 
150  // Close the group of entities
151  errorStatus = catiav5w::CloseCurrentNode();
152  if( errorStatus != dtkNoError )
153  {
154  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
155  return errorStatus;
156  }
157 
158 
159  Dtk_InfoPtr MyOpenShellInfo = Dtk_Info::Create();
160  MyOpenShellInfo->SetName( L"MyOpenShell" );
161  MyOpenShellInfo->SetLayer( 123 );
162  MyOpenShellInfo->SetColor( Dtk_RGB( 255, 255, 0 ) );
163  MyOpenShellInfo->SetBlankedStatus( DTK_TRUE );
164  errorStatus = catiav5w::CreateNode( catiav5w::NodeTypeGeometricSet, MyOpenShellInfo );
165  if( errorStatus != dtkNoError )
166  {
167  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
168  return errorStatus;
169  }
170 
171  ////Writing OpenShell entity
172  Dtk_InfoPtr& body_openshellInfo = body_openshell->info();
173  if( body_openshellInfo.IsNULL() )
174  {
175  body_openshellInfo = Dtk_Info::Create();
176  }
177  body_openshellInfo->SetColor( Dtk_RGB( 0, 255, 0 ) );
178  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( body_openshell ) );
179  if( errorStatus != dtkNoError )
180  {
181  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
182  return errorStatus;
183  }
184 
185  // Close the group of entities
186  errorStatus = catiav5w::CloseCurrentNode();
187  if( errorStatus != dtkNoError )
188  {
189  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
190  return errorStatus;
191  }
192 
193 
194  // We create a solid group with a name
195  Dtk_InfoPtr MySolidInfo = Dtk_Info::Create();
196  MySolidInfo->SetName( L"My Solid" );
197  MySolidInfo->SetLayer( 12 );
198  MySolidInfo->SetColor( Dtk_RGB( 255, 0, 255 ) );
199 
200  //The material is assigned on the node info so it applies to the whole PartBody
201  errorStatus = WriteBodyMaterial( MySolidInfo );
202  if( errorStatus != dtkNoError )
203  {
204  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
205  return errorStatus;
206  }
207 
208  errorStatus = catiav5w::CreateNode( catiav5w::NodeTypePartBody, MySolidInfo );
209  if( errorStatus != dtkNoError )
210  {
211  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
212  return errorStatus;
213  }
214 
215  // And we write body in the catiav5 file
216  Dtk_InfoPtr& body_solidInfo = body_solid->info();
217  if( body_solidInfo.IsNULL() )
218  {
219  body_solidInfo = Dtk_Info::Create();
220  }
221  body_solidInfo->SetColor( Dtk_RGB( 255, 0, 0 ) );
222  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( body_solid ) );
223  if( errorStatus != dtkNoError )
224  {
225  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
226  return errorStatus;
227  }
228 
229  // Close the group of entities
230  errorStatus = catiav5w::CloseCurrentNode();
231  if( errorStatus != dtkNoError )
232  {
233  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
234  return errorStatus;
235  }
236 
237  Dtk_InfoPtr MyOpenShellForMeshInfo = Dtk_Info::Create();
238  MyOpenShellForMeshInfo->SetName( L"MyOpenShellForMesh" );
239  errorStatus = catiav5w::CreateNode( catiav5w::NodeTypeGeometricSet, MyOpenShellForMeshInfo );
240  if( errorStatus != dtkNoError )
241  {
242  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
243  return errorStatus;
244  }
245 
246  ////Writing Mesh entity
247  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( mesh ) );
248  if( errorStatus != dtkNoError )
249  {
250  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
251  return errorStatus;
252  }
253 
254  // Close the group of entities
255  errorStatus = catiav5w::CloseCurrentNode();
256  if( errorStatus != dtkNoError )
257  {
258  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
259  return errorStatus;
260  }
261 
262  Dtk_InfoPtr MyOpenShellForPlaneInfo = Dtk_Info::Create();
263  MyOpenShellForPlaneInfo->SetName( L"MyOpenShellForPlane" );
264  errorStatus = catiav5w::CreateNode( catiav5w::NodeTypeGeometricSet, MyOpenShellForPlaneInfo );
265  if( errorStatus != dtkNoError )
266  {
267  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
268  return errorStatus;
269  }
270 
271  ////Writing Plane entity
272  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( body_plane ) );
273  if( errorStatus != dtkNoError )
274  {
275  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
276  return errorStatus;
277  }
278 
279  // Close the group of entities
280  errorStatus = catiav5w::CloseCurrentNode();
281  if( errorStatus != dtkNoError )
282  {
283  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
284  return errorStatus;
285  }
286 
287  Dtk_InfoPtr MyOpenShellForInifiniteLineInfo = Dtk_Info::Create();
288  MyOpenShellForInifiniteLineInfo->SetName( L"MyOpenShellForInifiniteLine" );
289  errorStatus = catiav5w::CreateNode( catiav5w::NodeTypeGeometricSet, MyOpenShellForInifiniteLineInfo );
290  if( errorStatus != dtkNoError )
291  {
292  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
293  return errorStatus;
294  }
295 
296  ////Writing Plane entity
297  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( body_axis ) );
298  if( errorStatus != dtkNoError )
299  {
300  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
301  return errorStatus;
302  }
303 
304  // Close the group of entities
305  errorStatus = catiav5w::CloseCurrentNode();
306  if( errorStatus != dtkNoError )
307  {
308  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
309  return errorStatus;
310  }
311 
312  //Now we will create an AxisSystem
314  if( errorStatus != dtkNoError )
315  {
316  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
317  return errorStatus;
318  }
319 
320  //we write it now
321  errorStatus = catiav5w::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( TmpAxis ) );
322  if( errorStatus != dtkNoError )
323  {
324  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
325  return errorStatus;
326  }
327 
328  //We create a default Named View - Camera -
329  //For that we firstly create a camera
331  Dtk_pnt( 200, 100, 100 ), //Origin Point
332  Dtk_pnt( 0, 100, 100 ), //Target Point
333  100., 100., //SemiWidth / SemiHeight
334  Dtk_dir( 0, 1, 0 ) ); //Up Vector - can be reprocessed by CatiaV5 if needed -
335 
336  //We create the model display from the camera
337  //We don't put any clipping entity - not used by V5 write -
338  //The 3rd parameter set the Named View as the default one - used at the V5 file opening -
339  Dtk_ModelDisplayPtr NamedView = Dtk_ModelDisplay::Create( Cam, NULL, DTK_TRUE );
340  //We don't need any name because the default Named View name is hardcoded
341  //Finally we write the NamedView
342  errorStatus = catiav5w::WriteNamedView( NamedView );
343  if( errorStatus != dtkNoError )
344  {
345  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
346  return errorStatus;
347  }
348 
349 
350  //Now we create another named view
351  Cam = Dtk_Camera::Create( Dtk_pnt( 100, 100, 100 ), Dtk_pnt( 0, 0, 0 ), 100., 100., Dtk_dir( 0, 1, 0 ) );
352  //Not set as default => will appear in the 'Named Views' Dialog Box into Catia V5
353  NamedView = Dtk_ModelDisplay::Create( Cam, NULL, DTK_FALSE );
354  NamedView->info() = Dtk_Info::Create();
355  //We put the Named view name
356  NamedView->info()->SetName( L"MyNamedView" );
357  //Finally we write the NamedView
358  errorStatus = catiav5w::WriteNamedView( NamedView );
359  if( errorStatus != dtkNoError )
360  {
361  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
362  return errorStatus;
363  }
364 
365  //Now we write layer data - Layers Names and Layer Filters -
366  errorStatus = WriteLayerData();
367  if( errorStatus != dtkNoError )
368  {
369  std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
370  return errorStatus;
371  }
372 
373  // Close the current part
374  errorStatus = catiav5w::EndPart();
375 
376  return errorStatus;
377 }

◆ resolvePath()

std::wstring resolvePath ( const std::wstring &  inRelativePath)
27 {
28 #ifdef _MSC_VER
29  wchar_t buffer[ MAX_PATH ];
30  DWORD len = GetFullPathNameW( inRelativePath.c_str(), MAX_PATH, buffer, nullptr );
31  return std::wstring( buffer, len );
32 #else
33  // --- Linux/macOS : std::string ---
34  // Simply convert the wstring to a plain string
35  // (assumes UTF-8 if the source file is encoded in UTF-8)
36  std::string utf8( inRelativePath.begin(), inRelativePath.end() );
37 
38  char buffer[ PATH_MAX ];
39  if( realpath( utf8.c_str(), buffer ) != nullptr )
40  {
41  // Convert back to a simple wstring
42  return std::wstring( buffer, buffer + strlen( buffer ) );
43  }
44  else
45  {
46  return inRelativePath; // path does not exist
47  }
48 #endif
49 }

◆ WriteBodyMaterial()

Dtk_ErrorStatus WriteBodyMaterial ( const Dtk_InfoPtr &  inNodeInfo)
65 {
66  //CATIA requires at least the Lighting data to be set for the material to be considered valid; otherwise the material will render as gray
67  catiav5w::Material material( L"BlueMaterial" );
68  material.m_Lighting.SetAmbientData( Dtk_RGB( 40, 40, 255 ), 0.6 );
69  material.m_Lighting.SetDiffuseData( Dtk_RGB( 80, 80, 255 ), 1.0 );
70  material.m_Lighting.SetSpecularData( Dtk_RGB( 255, 255, 255 ), 0.9 );
71  material.m_Lighting.SetTransparencyData( Dtk_RGB( 0, 0, 0 ), 0. );
72  material.m_Lighting.SetReflectivityCoefficient( 0.4 );
73 
74  //...and its physical aspect - used for mass properties computation -
75  material.m_Analysis.SetDensity( 7850. ); //kg/m3 - Steel -
76 
77  //We add the material to the CATPart context...
78  catiav5w::MaterialId materialId;
79  Dtk_ErrorStatus errorStatus = catiav5w::AddMaterial( material, materialId );
80  if( errorStatus != dtkNoError )
81  {
82  return errorStatus;
83  }
84 
85  //...and we assign it to the node through its Info
86  return inNodeInfo->SetRenderInfosId( materialId );
87 }

◆ WriteLayerData()

Dtk_ErrorStatus WriteLayerData ( )
54 {
55  //Keep in mind that layer data can only be set into CATPart context.
56  auto layerInfoSet = sampleWriter::layer::CreateSetWithFilters();
57 
58  //We send layer data to the writer
59  return catiav5w::SetLayerData( layerInfoSet );
60 }
sampleWriter::CreateAxis
Dtk_BodyPtr CreateAxis()
Creates a reference body (infinite + reference flags) containing a single named axis line with metada...
Definition: testcreatecube.cpp:1568
Dtk_Info::Create
static Dtk_SmartPtr< Dtk_Info > Create()
Calls default constructor to allocate a new object.
Dtk_ModelDisplay::Create
static Dtk_ModelDisplayPtr Create(const Dtk_CameraPtr &inCamera, const Dtk_EntityPtr &inClippingEntity, const Dtk_bool inIsActivated)
Calls full featured constructor to allocate a new object.
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:688
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
catiav5w::InitVirtualComponent
Dtk_ErrorStatus InitVirtualComponent(const Dtk_string &inReferenceName, const catiav5w::FileDescription &inFileDescription=catiav5w::FileDescription())
Initialize a virtual component during CATProduct process.
catiav5w::OverrideInstanceAlphaWithPathID
Dtk_ErrorStatus OverrideInstanceAlphaWithPathID(const PathID &inInstancePathId, const Dtk_UChar8 inInstanceAlpha)
Override the Alpha of an instance in a Sub Product.
catiav5w::AddMaterial
Dtk_ErrorStatus AddMaterial(const Material &inMaterial, MaterialId &outMaterialId)
Add a Material in a CATPart context.
catiav5w::AddVirtualComponentInstance
Dtk_ErrorStatus AddVirtualComponentInstance(const Dtk_ID &inDocId, const Dtk_string &inInstanceName, const Dtk_transfo &inTransfo, Dtk_ID &outInstanceId)
Add an instance to a DocID into the Current (Sub/Root) CATProduct.
Dtk_Info::SetName
Dtk_ErrorStatus SetName(Dtk_string inName)
ProcessAsm
Dtk_ErrorStatus ProcessAsm(const Dtk_string &inResultDirectory, const Dtk_string &inInputFilesDirectory)
Writes a CATProduct assembly: one sub-product referencing a CATPart and one instanced directly from a...
Definition: testlibcatiav5write.cpp:380
catiav5w::WriteOptions
This class provides several options to tunes CatiaV5 Writter. It must be provided to catiav5w::InitWr...
Definition: catiav5w.hpp:41
Dtk_transfo::setOrigin
void setOrigin(const Dtk_pnt &O)
Set a new O center point.
catiav5w::NodeTypeGeometricSet
@ NodeTypeGeometricSet
Definition: catiav5w.hpp:411
catiav5w::Material
This is the wrapper class handling V5 write material data.
Definition: catiav5w.hpp:99
DTK_TRUE
#define DTK_TRUE
Definition: define.h:726
ProcessPart
Dtk_ErrorStatus ProcessPart(const Dtk_string &inOutputFile, const Dtk_string &inReferenceName)
Definition: testlibcatiav5write.cpp:90
Dtk_Info::SetRenderInfosId
Dtk_ErrorStatus SetRenderInfosId(const Dtk_ID &inRenderId)
sampleWriter::CreateInfinitePlane
Dtk_BodyPtr CreateInfinitePlane()
Creates a reference body flagged as an infinite plane (InfiniteGeometryFlag + RefEntityFlag),...
Definition: testcreatecube.cpp:1511
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
catiav5w::WriteEntity
Dtk_ErrorStatus WriteEntity(const Dtk_EntityPtr &inEntity)
Write the entity provided in parameter.
Dtk_UUID
Definition: dtk_uuid.hpp:8
sampleWriter::CreateAxisSystem
Dtk_AxisSystemPtr CreateAxisSystem()
Creates a named axis system with a custom orientation matrix, red color, layer 123,...
Definition: testcreatecube.cpp:1541
DTK_FALSE
#define DTK_FALSE
Definition: define.h:727
catiav5w::OverrideInstanceColorWithPathID
Dtk_ErrorStatus OverrideInstanceColorWithPathID(const PathID &inInstancePathId, const Dtk_RGB &inInstanceColor)
Override the Color of an instance in a Sub Product.
catiav5w::CreateNode
Dtk_ErrorStatus CreateNode(const NodeType &inNodeType, const Dtk_string &inNodeName=Dtk_string())
Create a node in the Specification Tree.
catiav5w::InitProduct
Dtk_ErrorStatus InitProduct(const Dtk_string &inFileName, const Dtk_string &inReferenceName, const catiav5w::FileDescription &inFileDescription=catiav5w::FileDescription())
Initialize a sub Product during CATProduct process.
Dtk_Info::SetBlankedStatus
Dtk_ErrorStatus SetBlankedStatus(const Dtk_Int32 &inBlankedStatus)
catiav5w::CreateCGRDocId
Dtk_ErrorStatus CreateCGRDocId(const Dtk_string &inCGRFileName, const Dtk_string &inCGRName, Dtk_ID &outDocId)
Create a CGR Reference and DocID related to a given CGR File.
catiav5w::inReferenceName
const Dtk_string & inReferenceName
Definition: catiav5w.hpp:432
catiav5w::InitPart
Dtk_ErrorStatus InitPart(const Dtk_string &inOutputFile, const Dtk_string &inReferenceName, Dtk_UUID &outPartUUID, const catiav5w::FileDescription &inFileDescription=catiav5w::FileDescription())
Initialize the part
Dtk_string::replace
int replace(const int &old_char, const int &new_char)
Replaces all occurrences of a character in a string with a new character.
sampleWriter::CreatePoint
Dtk_BodyPtr CreatePoint()
Creates a wireframe body containing a single named red point with metadata.
Definition: testcreatecube.cpp:1483
catiav5w::NodeTypePartBody
@ NodeTypePartBody
Definition: catiav5w.hpp:412
catiav5w::EndVirtualComponent
Dtk_ErrorStatus EndVirtualComponent(Dtk_ID &outDocId)
End - and write - the virtual component initialized by catiav5w::InitVirtualComponent.
Dtk_SmartPtr< Dtk_Entity >::DtkDynamicCast
static Dtk_SmartPtr< Dtk_Entity > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
catiav5w::AddInstance
Dtk_ErrorStatus AddInstance(const Dtk_ID &inDocId, const Dtk_string &inInstanceName, const Dtk_transfo &inTransfo, Dtk_ID &outInstanceId)
Add an instance to a DocID into the Current (Sub/Root) CATProduct.
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_SmartPtr::IsNULL
Dtk_bool IsNULL() const
Definition: util_ptr_dtk.hpp:118
catiav5w::CreateV4ModelDocId
Dtk_ErrorStatus CreateV4ModelDocId(const Dtk_string &inV4ModelFileName, const Dtk_string &inV4ModelName, Dtk_ID &outDocId)
Create a V4 Model Reference and DocID related to a given V4 Model File.
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
catiav5w::EndWrite
Dtk_ErrorStatus EndWrite()
Free the Catia V5 Writer
catiav5w::WriteOptions::SetFileRelease
Dtk_ErrorStatus SetFileRelease(const Dtk_UInt32 inRelease)
Sets the release for the written files.
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
catiav5w::CreatePartDocId
Dtk_ErrorStatus CreatePartDocId(const Dtk_string &inPartFileName, const Dtk_string &inPartName, Dtk_ID &outDocId)
Create a Part Reference and DocID related to a given CATPart.
sampleWriter::layer::CreateSetWithFilters
Dtk_LayerInfosSetPtr CreateSetWithFilters()
Creates a layer info set with 9 layers and 2 named layer filters grouping subsets of those layers.
Definition: testcreatelayerinfoset.cpp:27
catiav5w::MaterialId
Dtk_ID MaterialId
Definition: catiav5w.hpp:27
sampleWriter::CreateMeshCylinder
Dtk_MeshPtr CreateMeshCylinder(int nbpoints)
Mesh Cylinder sample.
Definition: testcreatemesh.cpp:338
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_Info::SetLayer
Dtk_ErrorStatus SetLayer(const Dtk_Int32 &inLayer)
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:20
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
Dtk_Camera::Create
static Dtk_CameraPtr Create()
Calls default constructor to allocate a new object.
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:84
sampleWriter::CreateCube
Dtk_BodyPtr CreateCube()
Creates a 100x100x100 mm closed BRep cube body. Builds the full BRep hierarchy (Vertex,...
Definition: testcreatecube.cpp:1325
catiav5w::EndProduct
Dtk_ErrorStatus EndProduct(Dtk_ID &outDocId)
Write effectively the Sub Product initialized by catiav5w::InitProduct.
resolvePath
std::wstring resolvePath(const std::wstring &inRelativePath)
Definition: testlibcatiav5write.cpp:26
catiav5w::CloseCurrentNode
Dtk_ErrorStatus CloseCurrentNode()
close the current node previously created by catiav5w::CreateNode.
catiav5w::SetLayerData
Dtk_ErrorStatus SetLayerData(const Dtk_LayerInfosSetPtr &inLayerDataSet)
Set Layer and LayerFilter Data in a CATPart context.
sampleWriter::CreateCurves
Dtk_BodyPtr CreateCurves()
Creates a wireframe body containing a circle, ellipse, line, and NURBS curve, each with a distinct co...
Definition: testcreatecube.cpp:1368
catiav5w::WriteNamedView
Dtk_ErrorStatus WriteNamedView(const Dtk_ModelDisplayPtr &inNamedView)
Write the given ModelDisplay as NamedView - V5 camera -.
catiav5w::EndPart
Dtk_ErrorStatus EndPart()
Free data allocated by catiav5w::InitPart
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:151
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:416
catiav5w::InitWrite
Dtk_ErrorStatus InitWrite(const Dtk_string &inLogFile, Licence_dtk inLicFct, const WriteOptions &inOptions=WriteOptions())
Initialize the Catia V5 Writer
Dtk_RGB
Definition: dtk_rgb.hpp:8
Dtk_Info::SetColor
Dtk_ErrorStatus SetColor(const int &R, const int &G, const int &B)
WriteLayerData
Dtk_ErrorStatus WriteLayerData()
Definition: testlibcatiav5write.cpp:53
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:14
catiav5w::OverrideBlankedStatusWithPathID
Dtk_ErrorStatus OverrideBlankedStatusWithPathID(const PathID &inInstancePathId, const Dtk_bool inBlankedStatus)
Override the Blanked Status of an instance in a Sub Product.
WriteBodyMaterial
Dtk_ErrorStatus WriteBodyMaterial(const Dtk_InfoPtr &inNodeInfo)
Definition: testlibcatiav5write.cpp:64
sampleWriter::CreateOpenShell
Dtk_BodyPtr CreateOpenShell()
Creates an open shell body containing a single trimmed cylindrical surface (half cylinder,...
Definition: testcreatecube.cpp:1353