DATAKIT API  V2025.1
IGES Write Sample
//start_of_mainigeswrite
{
int status;
Dtk_BodyPtr Cube = NULL;
Dtk_BodyPtr Openshell = NULL;
Dtk_BodyPtr WireShell = NULL;
Dtk_tab<Dtk_ID> IgesIndices;
Dtk_string outputFileName;
// Choosing output file name
outputFileName = "../SampleFiles/dtk/sample.igs";
// Cube Sample
// Open Shell Sample
//WireShell Sample
//Fdt Sample
// First we initialize writing
Igesw::IgesMetaData inGlobalSection;
status = Igesw::InitWrite( outputFileName, Dtk_string( "testigesw.log" ), inGlobalSection );
cout << "Igesw Write init: " << dtkTypeError( status ).c_str() << endl;
if( status != 0 )
{
cout << "Igesw Write aborted" << endl;
return -1;
}
Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Openshell ), 0, IgesIndices );
Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( WireShell ), 0, IgesIndices );
return err;
}
int IgesAssemblySample( const Dtk_string &inResultDirectory )
{
int status;
Dtk_BodyPtr Cube = NULL;
Dtk_BodyPtr Openshell = NULL;
Dtk_BodyPtr WireShell = NULL;
Dtk_string outputFileName, outputDirectory;
Dtk_tab<Dtk_ID> IgesIndices;
Dtk_ID ProtoIndex, InstanceIndex, Instance1, Instance2;
Dtk_transfo transfo;
// Choosing output directory and file name
outputDirectory = inResultDirectory + L"dtk/Iges/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
outputFileName = outputDirectory + L"assemblysample.igs";
// Cube Sample
//WireShell Sample
// First we initialize writing
Igesw::IgesMetaData inGlobalSection;
status = Igesw::InitWrite( outputFileName, Dtk_string( outputDirectory + L"assemblyigesw.log" ), inGlobalSection );
if( status != 0 )
{
cout << "error : " << dtkTypeError( status ).c_str() << endl;
return status;
}
err = Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Cube ), 1, IgesIndices );
info->SetName( "Cube" );
err = Igesw::WritePrototype( IgesIndices, info, ProtoIndex );
err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 1, Instance1 );
transfo.addTranslate( Dtk_dir( 120.0, 120.0, 0 ) );
err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 1, Instance2 );
IgesIndices.clear();
IgesIndices.push_back( Instance1 );
IgesIndices.push_back( Instance2 );
err = Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( WireShell ), 1, IgesIndices );
info->SetName( "CProto" );
info->SetColor( Dtk_RGB() );
err = Igesw::WritePrototype( IgesIndices, info, ProtoIndex );
transfo.addTranslate( Dtk_dir( 0, 0, 0 ) );
info->SetName( "Green" );
info->SetColor( Dtk_RGB( 0, 255, 0 ) );
err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 0, InstanceIndex );
info->SetName( "Red" );
info->SetColor( Dtk_RGB( 255, 0, 0 ) );
transfo.addTranslate( Dtk_dir( 0, 0, 150 ) );
err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 0, InstanceIndex );
cout << "=> " << outputFileName.c_str() << endl;
return err;
}
int IgesWriteSample( const Dtk_string &inResultDirectory )
{
cout << endl << "----------------------------------------------" << endl;
cout << "Iges Write start" << endl;
//Standard Iges Sample File Processing
int err = IgesAssemblySample( inResultDirectory );
cout << "Iges Write end" << endl;
return err;
}
//end_of_mainigeswrite
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:689
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Igesw::WritePrototype
Dtk_ErrorStatus WritePrototype(const Dtk_tab< Dtk_ID > &inIndices, const Dtk_InfoPtr &inProtoInfos, Dtk_ID &outProtoIndex)
Write a Prototype 308 subfigure entity
Dtk_Info::SetName
Dtk_ErrorStatus SetName(Dtk_string inName)
Igesw::WriteEntity
Dtk_ErrorStatus WriteEntity(const Dtk_EntityPtr &inEntity, Dtk_Char8 inDependancyFlag, Dtk_tab< Dtk_ID > &outIndices)
Write an entity
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Igesw::IgesMetaData
Definition: igesw.hpp:7
Igesw::InstanciatePrototype
Dtk_ErrorStatus InstanciatePrototype(Dtk_ID inProtoIndex, const Dtk_transfo &inPlacement, const Dtk_InfoPtr &inInstanceInfos, Dtk_Char8 inDependancyFlag, Dtk_ID &outInstanceIndex)
Write a Instance 408 figure entity
Igesw::EndWrite
DtkErrorStatus EndWrite()
Creation of the output file and free the Iges Writer
Igesw::InitWrite
DtkErrorStatus InitWrite(const Dtk_string &inOutputFile, const Dtk_string &inLogFile, IgesMetaData inHeaderInformations)
Initialize the Iges Writer
sampleWriter::CreateFdtDatum
Dtk_FdtPtr CreateFdtDatum()
Create Simple Datum.
Definition: testcreatefdt.cpp:19
IgesAssemblySample
int IgesAssemblySample(const Dtk_string &inResultDirectory)
Definition: testlibigeswrite.cpp:71
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)
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_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
Dtk_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
sampleWriter::CreateCube
Dtk_BodyPtr CreateCube()
Definition: testcreatecube.cpp:1249
sampleWriter::CreateCurves
Dtk_BodyPtr CreateCurves()
Definition: testcreatecube.cpp:1292
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:140
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:415
Dtk_tab::clear
void clear(int no_delete=0)
Resets the Dtk_tab content.
Definition: util_stl_dtk.hpp:351
sampleWriter::CreateOpenShell
void CreateOpenShell(std::map< Dtk_ID, Dtk_EntityPtr > &outArrayTopo, const Dtk_BodyPtr &inDtkBody)
Definition: testcreatecube.cpp:1194
Dtk_RGB
Definition: dtk_rgb.hpp:7
Dtk_Info::SetColor
Dtk_ErrorStatus SetColor(const int &R, const int &G, const int &B)
Dtk_Info::create
static Dtk_SmartPtr< Dtk_Info > create()
IgesWriteSample
int IgesWriteSample(const Dtk_string &inResultDirectory)
Definition: testlibigeswrite.cpp:147
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
IgesStandardSample
int IgesStandardSample()
Definition: testlibigeswrite.cpp:20