DATAKIT SDK  V2026.4
LibReadersSampleToParasolid/main.cpp File Reference

Functions

int LaunchAPISampleToParasolid (int argc, char **argv)
 
int main (int argc, char **argv)
 
static void PrintUsage (char *executableName)
 

Function Documentation

◆ LaunchAPISampleToParasolid()

int LaunchAPISampleToParasolid ( int  argc,
char **  argv 
)
32 {
33  // Enable all available Datakit readers.
34  EnableReaders();
35 
36  // Retrieve the current working directory so the Datakit API has a writable
37  // temporary directory available.
38 #ifndef Linux
39  wchar_t workingDirectory[ 1024 ];
40  wchar_t* retwc = _wgetcwd( workingDirectory, 1024 );
41  (void)retwc;
42 #else
43  char workingDirectory[ 1024 ];
44  getcwd( workingDirectory, 1024 );
45 #endif
46 
47  // Start the Datakit API.
48  Dtk_ErrorStatus errorStatus = dtkNoError;
49  cout << "Starting DATAKIT API" << endl;
50  Dtk_API* myAPI = Dtk_API::StartAPI( workingDirectory, errorStatus );
51  if( myAPI == NULL )
52  {
53  cout << "Cannot start DATAKIT API: " << errorStatus << endl;
54  return dtkErrorAPINotStarted;
55  }
56 
57  // Apply optional API settings (unit, tessellation quality, …).
58  ActivateApiOptions( myAPI );
59 
60  // Preserve native kernel data during reading if parasolid daata are stored in original file so that psw can write the
61  // original kernel geometry.
62  myAPI->ActivateKeepKernelData();
63 
64  // Set the schema directory
65  SetSchemaDirectory( myAPI );
66 
67  // Process each input file.
68  for( int i = 1; i < argc; ++i )
69  {
70  Dtk_string inputFile = argv[ i ];
71 
72  time_t startTime;
73  time( &startTime );
74 
75  // Output is written alongside the input file (empty folder = same dir).
76  Dtk_ErrorStatus curError = ProcessCADFileToParasolid( inputFile, "" );
77 
78  time_t stopTime;
79  time( &stopTime );
80 
81  if( curError != dtkNoError )
82  {
83  cout << "Error processing file " << inputFile.c_str()
84  << " (" << dtkTypeError( curError ).c_str() << ")" << endl;
85  }
86  else
87  {
88  double elapsedTime = difftime( stopTime, startTime );
89  cout << "File " << inputFile.c_str()
90  << " processed in " << elapsedTime << " s" << endl;
91  }
92  }
93 
94  // Stop the Datakit API and release all resources.
95  Dtk_API::StopAPI( myAPI );
96  cout << "Stopping DATAKIT API" << endl;
97 
98  return 0;
99 }

◆ main()

int main ( int  argc,
char **  argv 
)
38 {
39 #ifndef Linux
40  _wchdir( L"../../bin" );
41 #endif
42 
43  if( argc < 2 )
44  {
45  PrintUsage( argv[ 0 ] );
46  return 1;
47  }
48 
49  return LaunchAPISampleToParasolid( argc, argv );
50 }

◆ PrintUsage()

static void PrintUsage ( char *  executableName)
static
18 {
19  std::cout << "Usage:\n";
20  std::cout << " " << executableName << " <InputFile1> <InputFile2>\n";
21  std::cout << "\n";
22  std::cout << "Arguments:\n";
23  std::cout << " <InputFile> Mandatory parameter: Path to one or more input files\n";
24  std::cout << "\n";
25  std::cout << "Example:\n";
26  std::cout << " " << executableName << " \"../SampleFiles/Piston.CATPart\"\n";
27 }
PrintUsage
static void PrintUsage(char *executableName)
Definition: LibReadersSampleToParasolid/main.cpp:17
Dtk_API::StartAPI
static Dtk_API * StartAPI(const Dtk_string &inTemporyDirectory, Dtk_ErrorStatus &outErrorCode, const Dtk_string &inCustomerID=Dtk_string())
Start DATAKIT API.
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
SetSchemaDirectory
Dtk_ErrorStatus SetSchemaDirectory(Dtk_API *inoutMyApi)
Definition: LibReadersSample/RunThroughAPI/GetStarted/EnableReaders.cpp:82
ActivateApiOptions
void ActivateApiOptions(Dtk_API *inoutMyApi)
Definition: ActivateApiOptions.cpp:7
dtkErrorAPINotStarted
@ dtkErrorAPINotStarted
Definition: error_dtk.hpp:109
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.
LaunchAPISampleToParasolid
int LaunchAPISampleToParasolid(int argc, char **argv)
Definition: StartAPIToParasolid.cpp:31
ProcessCADFileToParasolid
Dtk_ErrorStatus ProcessCADFileToParasolid(const Dtk_string &inInputFile, const Dtk_string &inOutputFolder)
Definition: OpenDocumentToParasolid.cpp:18
Dtk_API::ActivateKeepKernelData
void ActivateKeepKernelData()
Keep Kernel Data option (see "How to use KeepKernelData option")
Dtk_API::StopAPI
static void StopAPI(Dtk_API *&inAPI, Dtk_bool inWriteTimeInLog=1)
Stop DATAKIT API.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:151
EnableReaders
void EnableReaders()
Definition: LibReadersSample/RunThroughAPI/GetStarted/EnableReaders.cpp:12
Dtk_API
Definition: dtk_api.hpp:75