DATAKIT API  V2025.1
LibReadersSample/main.cpp File Reference

Functions

void error_Script (char *scriptName)
 
int LaunchAPISample (int argc, char **argv)
 
int main (int argc, char **argv)
 

Function Documentation

◆ error_Script()

void error_Script ( char *  scriptName)
18 {
19  cout << "Usage: " << endl;
20  cout << scriptName << " [InputFile1] [InputFile2] ... " << endl;
21  cout << "\t For example use: EXE \"../SampleFiles/JT/toy.jt\"" << endl;
22  cout << "\t Argument is a file or a list of files to be processed" << endl;
23  cout << "\t ========================================================" << endl;
24  cout << "\t Files can come from Catiav5, NX, Solidworks,.... " << endl;
25 }

◆ LaunchAPISample()

int LaunchAPISample ( int  argc,
char **  argv 
)
41 {
42 
44  // Activates / deactivates 3D PDF file creation with geometrical, PMI, assembly, materials datas...
45  // This option requires Datakit tessellation
47 
48  // Activates / deactivates dumping of DTK classes to XML file
50 
51  // Activates / deactivates dumping of features (only implemented for CatiaV5, Proe, UG)
54 
55  //First You have to Enable the readers you want to use
56  EnableReaders();
57 
58  //Dtk_API need a working directory where it can write
59 #ifndef Linux
60  wchar_t TemporaryWorkingDirectory[1024];
61  wchar_t *retwc;
62  retwc = _wgetcwd(TemporaryWorkingDirectory, 1024);
63 #else
64  char TemporaryWorkingDirectory[1024];
65  getcwd(TemporaryWorkingDirectory, 1024);
66 #endif
67 
68  //Then You have to Start DATAKIT API with a temporary directory
69  Dtk_ErrorStatus errorStatus = dtkNoError;
70  cout << "Starting DATAKIT API " << endl;
71  Dtk_API * MyAPI = Dtk_API::StartAPI(TemporaryWorkingDirectory, errorStatus);
72  if (MyAPI == NULL)
73  {
74  cout << "Can't Start DATAKIT API : " << errorStatus << endl;
75  return dtkErrorAPINotStarted;
76  }
77 
78  ActivateApiOptions(MyAPI);
79 
80  //Initialization of tessellation library (used for PDF )
82  {
84  }
85 
86  //
87  Dtk_ErrorStatus SchemaStatus;
88  SchemaStatus = SetSchemaDirectory(MyAPI);
89 
90 
91 //Here are sample files coming from several CAD software or neutral format
92 //Integration is the same for all type of file
93 // Supported Extensions : sat,prt,asm,igs,iges,jt,vda,CATDrawing,CATPart,CATProduct,cgr,model,x_t,x_b,xmt,par,sldprt,step,stp,ipt,iam, dwg and more
94 
95  for (int i = 1; i < argc; i++)
96  {
97  Dtk_string InputFile = argv[i];
98  time_t StartTime;
99  time(&(StartTime));
100  Dtk_ErrorStatus curError = ProcessCADFile(InputFile, "");
101 
102  time_t StopTime;
103  time(&(StopTime));
104 
105  if (curError)
106  {
107  cout << "error processing file " << InputFile.c_str() << " (" << dtkTypeError(curError).c_str() << " s)" << endl;
108  }
109  else
110  {
111  double elaps_time = difftime(StopTime, StartTime);
112  cout << "file " << InputFile.c_str() << "processed during (" << elaps_time << " s)" << endl;
113  }
114  }
115 
116  if (IsPdfDumpActivated() == DTK_TRUE)
117  {//Close tessellation kernel
118  EndTesselation();
119  }
120 
121  //At the end you stop DATAKIT API
122  Dtk_API::StopAPI(MyAPI);
123  cout << "Stopping DATAKIT API " << endl;
124 
125  return 0;
126 }

◆ main()

int main ( int  argc,
char **  argv 
)
37 {
38 
39 #ifndef Linux
40  _wchdir(L"../../bin");
41 #endif
42 
43 
44  if (argc == 1)
45  {
46  error_Script(argv[0]);
47  return 1;
48  }
49  return LaunchAPISample(argc, argv);
50 }
error_Script
void error_Script(char *scriptName)
Definition: LibReadersSample/main.cpp:17
SetSchemaDirectory
Dtk_ErrorStatus SetSchemaDirectory(Dtk_API *inoutMyApi)
Definition: EnableReaders.cpp:78
ActivateApiOptions
void ActivateApiOptions(Dtk_API *inoutMyApi)
Definition: ActivateApiOptions.cpp:8
ActivatePdfDump
void ActivatePdfDump(Dtk_bool inDumpPDF)
Definition: PdfWrite.cpp:21
DTK_TRUE
#define DTK_TRUE
Definition: define.h:727
Dtk_API::StartAPI
static Dtk_API * StartAPI(const Dtk_string &inTemporyDirectory, Dtk_ErrorStatus &outErrorCode, const Dtk_string &inCustomerID=Dtk_string())
Start DATAKIT API.
InitTesselation
DtkErrorStatus InitTesselation()
Definition: TesselationEngine.cpp:13
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
ActivateFeatureDump
void ActivateFeatureDump(Dtk_bool inDumpFeature)
Definition: WriteFeature.cpp:7
DTK_FALSE
#define DTK_FALSE
Definition: define.h:728
dtkErrorAPINotStarted
@ dtkErrorAPINotStarted
Definition: error_dtk.hpp:101
ActivateXmlDump
void ActivateXmlDump(Dtk_bool inDumpXml)
Definition: XmlWrite.cpp:12
EndTesselation
void EndTesselation()
Definition: TesselationEngine.cpp:40
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
EnableReaders
void EnableReaders()
Definition: EnableReaders.cpp:12
LaunchAPISample
int LaunchAPISample(int argc, char **argv)
Definition: StartAPI.cpp:40
Dtk_API::StopAPI
static void StopAPI(Dtk_API *&inAPI, Dtk_bool inWriteTimeInLog=1)
Stop DATAKIT API.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:140
IsPdfDumpActivated
Dtk_bool IsPdfDumpActivated()
Definition: PdfWrite.cpp:26
Dtk_API
Definition: dtk_api.hpp:75
ProcessCADFile
Dtk_ErrorStatus ProcessCADFile(const Dtk_string &inInputFile, const Dtk_string &inOutputFolder)
Definition: OpenDocument.cpp:18