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

◆ IgesStandardSample()

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

◆ IgesWriteSample()

int IgesWriteSample ( const Dtk_string inResultDirectory)
148 {
149  cout << endl << "----------------------------------------------" << endl;
150  cout << "Iges Write start" << endl;
151  //Standard Iges Sample File Processing
152  int err = IgesAssemblySample( inResultDirectory );
153  cout << "Iges Write end" << endl;
154 
155  return err;
156 }
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()
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15