DATAKIT SDK  V2026.4
IGES Write Sample
//start_of_mainigeswrite
//! \brief Writes a single IGES file containing a cube, open shell, wireframe, and a datum FDT.
{
Dtk_ErrorStatus errorStatus = dtkNoError;
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 = "../OutputFiles/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 );
std::cout << "Igesw Write init: " << dtkTypeError( status ).c_str() << std::endl;
if( status != 0 )
{
std::cout << "Igesw Write aborted" << std::endl;
return -1;
}
Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Openshell ), 0, IgesIndices );
Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( WireShell ), 0, IgesIndices );
return errorStatus;
}
//! \brief Writes an IGES assembly: two products each containing BRep bodies, demonstrating multi-product IGES structure.
Dtk_ErrorStatus IgesAssemblySample( const Dtk_string &inResultDirectory )
{
Dtk_ErrorStatus errorStatus = dtkNoError;
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"Iges/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
outputFileName = outputDirectory + L"assemblysample.igs";
// Cube Sample
//WireShell Sample
// First we initialize writing
Igesw::IgesMetaData inGlobalSection;
errorStatus = Igesw::InitWrite( outputFileName, Dtk_string( outputDirectory + L"assemblyigesw.log" ), inGlobalSection );
if( errorStatus != 0 )
{
std::cout << "error : " << dtkTypeError( errorStatus ).c_str() << std::endl;
return errorStatus;
}
errorStatus = Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Cube ), 1, IgesIndices );
info->SetName( "Cube" );
errorStatus = Igesw::WritePrototype( IgesIndices, info, ProtoIndex );
errorStatus = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 1, Instance1 );
transfo.addTranslate( Dtk_dir( 120.0, 120.0, 0 ) );
errorStatus = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 1, Instance2 );
IgesIndices.clear();
IgesIndices.push_back( Instance1 );
IgesIndices.push_back( Instance2 );
errorStatus = Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( WireShell ), 1, IgesIndices );
info->SetName( "CProto" );
info->SetColor( Dtk_RGB() );
errorStatus = Igesw::WritePrototype( IgesIndices, info, ProtoIndex );
transfo.addTranslate( Dtk_dir( 0, 0, 0 ) );
info->SetName( "Green" );
info->SetColor( Dtk_RGB( 0, 255, 0 ) );
errorStatus = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 0, InstanceIndex );
info->SetName( "Red" );
info->SetColor( Dtk_RGB( 255, 0, 0 ) );
transfo.addTranslate( Dtk_dir( 0, 0, 150 ) );
errorStatus = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 0, InstanceIndex );
std::cout << "=> " << outputFileName.c_str() << std::endl;
return errorStatus;
}
DtkErrorStatus IgesWriteSample( const Dtk_string &inResultDirectory )
{
std::cout << std::endl << "----------------------------------------------" << std::endl;
std::cout << "Iges Write start" << std::endl;
//Standard Iges Sample File Processing
DtkErrorStatus errorStatus = IgesAssemblySample( inResultDirectory );
std::cout << "Iges Write end" << std::endl;
return errorStatus;
}
//end_of_mainigeswrite
Dtk_Info::Create
static Dtk_SmartPtr< Dtk_Info > Create()
Calls default constructor to allocate a new object.
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:688
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:53
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()
Creates simple Datum.
Definition: testcreatefdt.cpp:14
IgesWriteSample
DtkErrorStatus IgesWriteSample(const Dtk_string &inResultDirectory)
Definition: testlibigeswrite.cpp:145
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 ...
IgesAssemblySample
Dtk_ErrorStatus IgesAssemblySample(const Dtk_string &inResultDirectory)
Writes an IGES assembly: two products each containing BRep bodies, demonstrating multi-product IGES s...
Definition: testlibigeswrite.cpp:71
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:84
Dtk_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
sampleWriter::CreateCube
Dtk_BodyPtr CreateCube()
Creates a 100x100x100 mm closed BRep cube body. Builds the full BRep hierarchy (Vertex,...
Definition: testcreatecube.cpp:1325
sampleWriter::CreateCurves
Dtk_BodyPtr CreateCurves()
Creates a wireframe body containing a circle, ellipse, line, and NURBS curve, each with a distinct co...
Definition: testcreatecube.cpp:1368
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:151
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:416
Dtk_tab::clear
void clear(int no_delete=0)
Resets the Dtk_tab content.
Definition: util_stl_dtk.hpp:352
Dtk_RGB
Definition: dtk_rgb.hpp:8
Dtk_Info::SetColor
Dtk_ErrorStatus SetColor(const int &R, const int &G, const int &B)
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:14
IgesStandardSample
int IgesStandardSample()
Writes a single IGES file containing a cube, open shell, wireframe, and a datum FDT.
Definition: testlibigeswrite.cpp:19
sampleWriter::CreateOpenShell
Dtk_BodyPtr CreateOpenShell()
Creates an open shell body containing a single trimmed cylindrical surface (half cylinder,...
Definition: testcreatecube.cpp:1353