DATAKIT API  V2025.1
testlib3mfwrite.cpp File Reference

Functions

int _3mfWriteSample (const Dtk_string &inResultDirectory)
 

Function Documentation

◆ _3mfWriteSample()

int _3mfWriteSample ( const Dtk_string inResultDirectory)
17 {
19  Dtk_MeshPtr cubeMesh = NULL;
20  Dtk_MeshPtr cylinderMesh = NULL;
21  Dtk_string outputFileName, outputDirectory;
22 
23  cout << endl << "----------------------------------------------" << endl;
24  cout << "3mf Write start" << endl;
25 
26  // Choosing output directory and file name
27  outputDirectory = inResultDirectory + L"dtk/3mf/";
28  outputDirectory.FixPathSeparator();
29  outputDirectory.mkdir();
30  outputFileName = outputDirectory + L"sample.3mf";
31 
32  // Cube Sample
33  cubeMesh = sampleWriter::CreateMeshCube();
35 
36  // Cylinder Sample
37  cylinderMesh = sampleWriter::CreateMeshCylinder( 30 );
38 
39  // First we initialize writing
41  Dtk_3MFWriter *_3mfw = new Dtk_3MFWriter();
42  err = _3mfw->InitWrite( outputFileName, Dtk_string( "test3mfw.log" ), options );
43 
44  if( err != dtkNoError )
45  cout << "error : " << dtkTypeError( err ).c_str() << endl;
46 
47 
48  // Lets write a small part composed by one cube and one cylinder
49 
50  // Let write the cube
51  cubeMesh->info() = Dtk_Info::create();
52  cubeMesh->info()->SetName( "Cube" );
53 
54  if( err == dtkNoError )
55  err = _3mfw->WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cubeMesh ) );
56 
57  // Let write the cylinder
58  cylinderMesh->info() = Dtk_Info::create();
59  cylinderMesh->info()->SetName( "Cylinder" );
60 
61  if( err == dtkNoError )
62  err = _3mfw->WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinderMesh ) );
63 
64  // We finish process and free memory allocated for writing
65  _3mfw->EndWrite();
66  if( err == dtkNoError )
67  cout << "=> " << outputFileName.c_str() << endl << "3mf Write end" << endl;
68  delete _3mfw;
69  return err;
70 }
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:207
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
sampleWriter::FillFacesColors
void FillFacesColors(Dtk_MeshPtr &inoutCubeMesh)
Filling mesh faces with colors.
Definition: testcreatemesh.cpp:244
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:23
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:337
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:10
Dtk_3MFWriter::EndWrite
DtkErrorStatus EndWrite()
Creation of the output file and free the Obj Writer
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:140
Dtk_Info::create
static Dtk_SmartPtr< Dtk_Info > create()