DATAKIT API  V2025.1
OBJ Write Sample
//start_of_mainobjwrite
int StandardObjSample( const Dtk_string &inResultDirectory )
{
int status;
Dtk_MeshPtr cubeMesh = NULL;
Dtk_MeshPtr texturedMesh = NULL;
Dtk_string outputFileName, outputDirectory;
Dtk_transfo transfo;
Dtk_dir dir( 5, 0, 0 );
transfo.addTranslate( dir );
// Choosing output directory and file name
outputDirectory = inResultDirectory + L"dtk/Obj/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
outputFileName = outputDirectory + L"sample.obj";
// Cube Sample
// Cylinder Sample
texturedMesh = sampleWriter::CreateTexturedMeshCube( inResultDirectory + L"../InputImages/" );
// First we initialize writing
options.m_UseRender = DTK_TRUE;
status = Objw::InitWrite( outputFileName, Dtk_string( "testobjw.log" ), options );
if( status != 0 )
{
cout << "error : " << dtkTypeError( status ).c_str() << endl;
return status;
}
// Lets write a small part composed by one textured cube and one cube with colors
// Let's name the textured cube
texturedMesh->info()->SetName( "TexturedCube" );
// Let's write the textured cube
if( err == dtkNoError )
// Let's name the colored cube
cubeMesh->info()->SetName( "Cube" );
// We translate it before writing
cubeMesh->Transform( transfo );
// And finally write it
if( err == dtkNoError )
// We finish process and free memory allocated for writing
if( err == dtkNoError )
err = Objw::EndWrite();
cout << "=> " << outputFileName.c_str() << endl;
return err;
}
int ObjWriteSample( const Dtk_string &inResultDirectory )
{
cout << endl << "----------------------------------------------" << endl;
cout << "Obj Write start" << endl;
//Standard Obj Sample File Processing
int err = StandardObjSample( inResultDirectory );
cout << "Obj Write end" << endl;
return err;
}
//end_of_mainobjwrite
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:207
Objw::WriteEntity
Dtk_ErrorStatus WriteEntity(const Dtk_EntityPtr &inEntity, Dtk_transfo inMat=Dtk_transfo())
Write the entity provided in parameter in a node.
DTK_TRUE
#define DTK_TRUE
Definition: define.h:727
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Objw::WriteOptions::m_UseRender
bool m_UseRender
Use of Dtk_RGB or Dtk_RenderInfos.
Definition: objw.hpp:29
sampleWriter::FillFacesColors
void FillFacesColors(Dtk_MeshPtr &inoutCubeMesh)
Filling mesh faces with colors.
Definition: testcreatemesh.cpp:244
Objw::WriteOptions
This class provides several options to tune Obj Writer. It must be provided to Objw::InitWrite method...
Definition: objw.hpp:18
sampleWriter::CreateTexturedMeshCube
Dtk_MeshPtr CreateTexturedMeshCube(const Dtk_string &inImageDirectory)
Textured Mesh Cube sample.
Definition: testcreatemesh.cpp:272
Objw::InitWrite
DtkErrorStatus InitWrite(const Dtk_string &inOutputFile, const Dtk_string &inLogFile, WriteOptions &inOptions)
Initialize the Obj Writer
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_SmartPtr
Definition: util_ptr_dtk.hpp:37
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
Objw::EndWrite
DtkErrorStatus EndWrite()
Creation of the output file and free the Obj Writer
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
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_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
ObjWriteSample
int ObjWriteSample(const Dtk_string &inResultDirectory)
Definition: testlibobjwrite.cpp:79
StandardObjSample
int StandardObjSample(const Dtk_string &inResultDirectory)
Definition: testlibobjwrite.cpp:17
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:140
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15