DATAKIT SDK  V2026.1
testlib3mfwrite.cpp File Reference

Functions

int _3mfWriteSample (const Dtk_string &inResultDirectory)
 

Function Documentation

◆ _3mfWriteSample()

int _3mfWriteSample ( const Dtk_string inResultDirectory)
12 {
14  Dtk_MeshPtr cubeMesh = NULL;
15  Dtk_MeshPtr cylinderMesh = NULL;
16  Dtk_string outputFileName, outputDirectory;
17 
18  cout << endl << "----------------------------------------------" << endl;
19  cout << "3mf Write start" << endl;
20 
21  // Choosing output directory and file name
22  outputDirectory = inResultDirectory + L"3mf/";
23  outputDirectory.FixPathSeparator();
24  outputDirectory.mkdir();
25  outputFileName = outputDirectory + L"sample.3mf";
26 
27  // Cube Sample
28  cubeMesh = sampleWriter::CreateMeshCube();
30 
31  // Cylinder Sample
32  cylinderMesh = sampleWriter::CreateMeshCylinder( 30 );
33 
34  // First we initialize writing
36  Dtk_3MFWriter *_3mfw = new Dtk_3MFWriter();
37  err = _3mfw->InitWrite( outputFileName, Dtk_string( "test3mfw.log" ), options );
38 
39  if( err != dtkNoError )
40  cout << "error : " << dtkTypeError( err ).c_str() << endl;
41 
42 
43  // Lets write a small part composed by one cube and one cylinder
44 
45  // Let write the cube
46  cubeMesh->info() = Dtk_Info::create();
47  cubeMesh->info()->SetName( "Cube" );
48 
49  if( err == dtkNoError )
50  err = _3mfw->WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cubeMesh ) );
51 
52  // Let write the cylinder
53  cylinderMesh->info() = Dtk_Info::create();
54  cylinderMesh->info()->SetName( "Cylinder" );
55 
56  if( err == dtkNoError )
57  err = _3mfw->WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinderMesh ) );
58 
59  // We finish process and free memory allocated for writing
60  _3mfw->EndWrite();
61  if( err == dtkNoError )
62  cout << "=> " << outputFileName.c_str() << endl << "3mf Write end" << endl;
63  delete _3mfw;
64  return err;
65 }
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:204
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
sampleWriter::FillFacesColors
void FillFacesColors(Dtk_MeshPtr &inoutCubeMesh)
Filling mesh faces with colors.
Definition: testcreatemesh.cpp:241
Dtk_3MFWriter::InitWrite
DtkErrorStatus InitWrite(const Dtk_string &inOutputFile, const Dtk_string &inLogFile, const WriteOptions &inOptions)
Initialize the 3mf Writer
Dtk_3MFWriter::WriteOptions
This class provides several options to tune 3mf Writer. It must be provided to _3mfw::InitWrite metho...
Definition: 3mfw.hpp:29
Dtk_SmartPtr< Dtk_Entity >::DtkDynamicCast
static Dtk_SmartPtr< Dtk_Entity > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_3MFWriter::WriteEntity
Dtk_ErrorStatus WriteEntity(const Dtk_EntityPtr &inEntity)
Write the entity provided in parameter in a node.
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
sampleWriter::CreateMeshCylinder
Dtk_MeshPtr CreateMeshCylinder(int nbpoints)
Mesh Cylinder sample.
Definition: testcreatemesh.cpp:334
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
Dtk_3MFWriter
3MF Writer main class.
Definition: 3mfw.hpp:16
Dtk_3MFWriter::EndWrite
DtkErrorStatus EndWrite()
Creation of the output file and free the Obj Writer
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:147
Dtk_Info::create
static Dtk_SmartPtr< Dtk_Info > create()
Calls default constructor to allocate a new object.