DATAKIT API  V2025.1
3mf Write Sample
//start_of_main3mfwrite
int _3mfWriteSample( const Dtk_string &inResultDirectory )
{
Dtk_MeshPtr cubeMesh = NULL;
Dtk_MeshPtr cylinderMesh = NULL;
Dtk_string outputFileName, outputDirectory;
cout << endl << "----------------------------------------------" << endl;
cout << "3mf Write start" << endl;
// Choosing output directory and file name
outputDirectory = inResultDirectory + L"dtk/3mf/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
outputFileName = outputDirectory + L"sample.3mf";
// Cube Sample
// Cylinder Sample
cylinderMesh = sampleWriter::CreateMeshCylinder( 30 );
// First we initialize writing
Dtk_3MFWriter *_3mfw = new Dtk_3MFWriter();
err = _3mfw->InitWrite( outputFileName, Dtk_string( "test3mfw.log" ), options );
if( err != dtkNoError )
cout << "error : " << dtkTypeError( err ).c_str() << endl;
// Lets write a small part composed by one cube and one cylinder
// Let write the cube
cubeMesh->info() = Dtk_Info::create();
cubeMesh->info()->SetName( "Cube" );
if( err == dtkNoError )
err = _3mfw->WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cubeMesh ) );
// Let write the cylinder
cylinderMesh->info() = Dtk_Info::create();
cylinderMesh->info()->SetName( "Cylinder" );
if( err == dtkNoError )
err = _3mfw->WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinderMesh ) );
// We finish process and free memory allocated for writing
_3mfw->EndWrite();
if( err == dtkNoError )
cout << "=> " << outputFileName.c_str() << endl << "3mf Write end" << endl;
delete _3mfw;
return err;
}
//end_of_main3mfwrite
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
_3mfWriteSample
int _3mfWriteSample(const Dtk_string &inResultDirectory)
Definition: testlib3mfwrite.cpp:16
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()