DATAKIT SDK  V2026.4
testlibigeswrite.cpp File Reference

Functions

Dtk_ErrorStatus IgesAssemblySample (const Dtk_string &inResultDirectory)
 Writes an IGES assembly: two products each containing BRep bodies, demonstrating multi-product IGES structure. More...
 
int IgesStandardSample ()
 Writes a single IGES file containing a cube, open shell, wireframe, and a datum FDT. More...
 
DtkErrorStatus IgesWriteSample (const Dtk_string &inResultDirectory)
 

Function Documentation

◆ IgesAssemblySample()

Dtk_ErrorStatus IgesAssemblySample ( const Dtk_string &  inResultDirectory)

Writes an IGES assembly: two products each containing BRep bodies, demonstrating multi-product IGES structure.

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

◆ IgesStandardSample()

int IgesStandardSample ( )

Writes a single IGES file containing a cube, open shell, wireframe, and a datum FDT.

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

◆ IgesWriteSample()

DtkErrorStatus IgesWriteSample ( const Dtk_string &  inResultDirectory)
146 {
147  std::cout << std::endl << "----------------------------------------------" << std::endl;
148  std::cout << "Iges Write start" << std::endl;
149  //Standard Iges Sample File Processing
150  DtkErrorStatus errorStatus = IgesAssemblySample( inResultDirectory );
151  std::cout << "Iges Write end" << std::endl;
152 
153  return errorStatus;
154 }
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
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
sampleWriter::CreateOpenShell
Dtk_BodyPtr CreateOpenShell()
Creates an open shell body containing a single trimmed cylindrical surface (half cylinder,...
Definition: testcreatecube.cpp:1353