DATAKIT SDK  V2026.1
testlibigeswrite.cpp File Reference

Functions

int IgesAssemblySample (const Dtk_string &inResultDirectory)
 
int IgesStandardSample ()
 
int IgesWriteSample (const Dtk_string &inResultDirectory)
 

Function Documentation

◆ IgesAssemblySample()

int IgesAssemblySample ( const Dtk_string inResultDirectory)
67 {
69  int status;
70 
71  Dtk_BodyPtr Cube = NULL;
72  Dtk_BodyPtr Openshell = NULL;
73  Dtk_BodyPtr WireShell = NULL;
74 
75  Dtk_string outputFileName, outputDirectory;
77  Dtk_tab<Dtk_ID> IgesIndices;
78  Dtk_ID ProtoIndex, InstanceIndex, Instance1, Instance2;
79  Dtk_transfo transfo;
80 
81  // Choosing output directory and file name
82  outputDirectory = inResultDirectory + L"Iges/";
83  outputDirectory.FixPathSeparator();
84  outputDirectory.mkdir();
85  outputFileName = outputDirectory + L"assemblysample.igs";
86 
87  // Cube Sample
88  Cube = sampleWriter::CreateCube();
89 
90  //WireShell Sample
91  WireShell = sampleWriter::CreateCurves();
92 
93  // First we initialize writing
94  Igesw::IgesMetaData inGlobalSection;
95  status = Igesw::InitWrite( outputFileName, Dtk_string( outputDirectory + L"assemblyigesw.log" ), inGlobalSection );
96 
97  if( status != 0 )
98  {
100  cout << "error : " << dtkTypeError( status ).c_str() << endl;
101  return status;
102  }
103 
104  err = Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Cube ), 1, IgesIndices );
105 
106  info->SetName( "Cube" );
107 
108  err = Igesw::WritePrototype( IgesIndices, info, ProtoIndex );
109 
110  err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 1, Instance1 );
111 
112  transfo.addTranslate( Dtk_dir( 120.0, 120.0, 0 ) );
113 
114  err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 1, Instance2 );
115 
116  IgesIndices.clear();
117  IgesIndices.push_back( Instance1 );
118  IgesIndices.push_back( Instance2 );
119  err = Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( WireShell ), 1, IgesIndices );
120 
121  info->SetName( "CProto" );
122  info->SetColor( Dtk_RGB() );
123  err = Igesw::WritePrototype( IgesIndices, info, ProtoIndex );
124  transfo.addTranslate( Dtk_dir( 0, 0, 0 ) );
125 
126  info->SetName( "Green" );
127  info->SetColor( Dtk_RGB( 0, 255, 0 ) );
128  err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 0, InstanceIndex );
129 
130  info->SetName( "Red" );
131  info->SetColor( Dtk_RGB( 255, 0, 0 ) );
132  transfo.addTranslate( Dtk_dir( 0, 0, 150 ) );
133  err = Igesw::InstanciatePrototype( ProtoIndex, transfo, info, 0, InstanceIndex );
134 
135  Igesw::EndWrite();
136 
137  cout << "=> " << outputFileName.c_str() << endl;
138 
139  return err;
140 }

◆ IgesStandardSample()

int IgesStandardSample ( )
16 {
18  int status;
19 
20  Dtk_BodyPtr Cube = NULL;
21  Dtk_BodyPtr Openshell = NULL;
22  Dtk_BodyPtr WireShell = NULL;
23 
24  Dtk_tab<Dtk_ID> IgesIndices;
25 
26  Dtk_string outputFileName;
27  Dtk_InfoPtr info;
28 
29  // Choosing output file name
30  outputFileName = "../SampleFiles/dtk/sample.igs";
31 
32  // Cube Sample
33  Cube = sampleWriter::CreateCube();
34 
35  // Open Shell Sample
36  Openshell = sampleWriter::CreateOpenShell();
37 
38  //WireShell Sample
39  WireShell = sampleWriter::CreateCurves();
40 
41  //Fdt Sample
43 
44  // First we initialize writing
45  Igesw::IgesMetaData inGlobalSection;
46  status = Igesw::InitWrite( outputFileName, Dtk_string( "testigesw.log" ), inGlobalSection );
47 
48  cout << "Igesw Write init: " << dtkTypeError( status ).c_str() << endl;
49  if( status != 0 )
50  {
52  cout << "Igesw Write aborted" << endl;
53  return -1;
54  }
55 
56  Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Cube ), 0, IgesIndices );
57  Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Openshell ), 0, IgesIndices );
58  Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( WireShell ), 0, IgesIndices );
59  Igesw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( Datum ), 0, IgesIndices );
60 
62 
63  return err;
64 }

◆ IgesWriteSample()

int IgesWriteSample ( const Dtk_string inResultDirectory)
143 {
144  cout << endl << "----------------------------------------------" << endl;
145  cout << "Iges Write start" << endl;
146  //Standard Iges Sample File Processing
147  int err = IgesAssemblySample( inResultDirectory );
148  cout << "Iges Write end" << endl;
149 
150  return err;
151 }
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:692
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:15
IgesAssemblySample
int IgesAssemblySample(const Dtk_string &inResultDirectory)
Definition: testlibigeswrite.cpp:66
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:84
Dtk_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
sampleWriter::CreateCube
Dtk_BodyPtr CreateCube()
Definition: testcreatecube.cpp:1316
sampleWriter::CreateCurves
Dtk_BodyPtr CreateCurves()
Definition: testcreatecube.cpp:1357
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:147
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: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()
Calls default constructor to allocate a new object.
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:14
sampleWriter::CreateOpenShell
Dtk_BodyPtr CreateOpenShell()
Definition: testcreatecube.cpp:1343