DATAKIT SDK  V2026.4
mainWithSession.cpp File Reference

Functions

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

Function Documentation

◆ LaunchAPISampleToParasolidWithSession()

int LaunchAPISampleToParasolidWithSession ( int  argc,
char **  argv 
)
39 {
40  // Enable all available Datakit readers.
41  EnableReaders();
42 
43  // Retrieve the current working directory.
44 #ifndef Linux
45  wchar_t workingDirectory[ 1024 ];
46  wchar_t* retwc = _wgetcwd( workingDirectory, 1024 );
47  (void)retwc;
48 #else
49  char workingDirectory[ 1024 ];
50  getcwd( workingDirectory, 1024 );
51 #endif
52 
53  // Start the Datakit API.
54  Dtk_ErrorStatus errorStatus = dtkNoError;
55  cout << "Starting DATAKIT API" << endl;
56  Dtk_API* myAPI = Dtk_API::StartAPI( workingDirectory, errorStatus );
57  if( myAPI == NULL )
58  {
59  cout << "Cannot start DATAKIT API: " << errorStatus << endl;
60  return dtkErrorAPINotStarted;
61  }
62 
63  ActivateApiOptions( myAPI );
64 
65  // Preserve native kernel data so psw can write original kernel geometry.
66  myAPI->ActivateKeepKernelData();
67 
68  SetSchemaDirectory( myAPI );
69 
70  // Start a single PK session shared across all processed files.
72 
73  // Process each input file.
74  for( int i = 1; i < argc; ++i )
75  {
76  Dtk_string arg = argv[ i ];
77 
78  time_t startTime;
79  time( &startTime );
80 
81  // Convert to Parasolid via psw and receive bodies into the shared session.
82  Dtk_ErrorStatus curError =
84 
85  time_t stopTime;
86  time( &stopTime );
87 
88  if( curError != dtkNoError )
89  cout << "Error processing file " << arg.c_str()
90  << " (" << dtkTypeError( curError ).c_str() << ")" << endl;
91  else
92  {
93  double elapsedTime = difftime( stopTime, startTime );
94  cout << "File " << arg.c_str()
95  << " processed in " << elapsedTime << " s" << endl;
96  }
97  }
98 
99  // Enumerate all bodies accumulated in the shared PK session.
101 
102  // Stop the PK session, then stop the Datakit API.
104  cout << "--- Parasolid session closed ---" << endl;
105 
106  Dtk_API::StopAPI( myAPI );
107  cout << "Stopping DATAKIT API" << endl;
108 
109  return 0;
110 }

◆ main()

int main ( int  argc,
char **  argv 
)
31 {
32 #ifndef Linux
33  _wchdir( L"../../bin" );
34 #endif
35 
36  if( argc < 2 )
37  {
38  PrintUsage( argv[ 0 ] );
39  return 1;
40  }
41 
42  return LaunchAPISampleToParasolidWithSession( argc, argv );
43 }

◆ PrintUsage()

static void PrintUsage ( char *  executableName)
static
17 {
18  std::cout << "Usage:\n";
19  std::cout << " " << executableName << " <InputFile1> <InputFile2> ...\n";
20  std::cout << "\n";
21  std::cout << "Arguments:\n";
22  std::cout << " <InputFile> Path to one or more input CAD files\n";
23  std::cout << "\n";
24  std::cout << "Example:\n";
25  std::cout << " " << executableName << " \"../SampleFiles/Piston.CATPart\"\n";
26  std::cout << "\n";
27  std::cout << "Supported formats: CatiaV5, NX, SolidWorks, STEP, IGES, ...\n";
28 }
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
EnableReaders
void EnableReaders()
Definition: LibReadersSample/RunThroughAPI/GetStarted/EnableReaders.cpp:12
StartSharedPsSession
void StartSharedPsSession()
Definition: LoadBodiesIntoSession.cpp:140
dtkErrorAPINotStarted
@ dtkErrorAPINotStarted
Definition: error_dtk.hpp:109
EnumerateBodiesInSession
void EnumerateBodiesInSession()
Definition: LoadBodiesIntoSession.cpp:147
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
SetSchemaDirectory
Dtk_ErrorStatus SetSchemaDirectory(Dtk_API *inoutMyApi)
Definition: LibReadersSample/RunThroughAPI/GetStarted/EnableReaders.cpp:82
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
StopSharedPsSession
void StopSharedPsSession()
Definition: LoadBodiesIntoSession.cpp:141
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.
ProcessCADFileToParasolidWithExistingSession
Dtk_ErrorStatus ProcessCADFileToParasolidWithExistingSession(const Dtk_string &inInputFile, const Dtk_string &inOutputFolder)
Definition: OpenDocumentToParasolidWithExistingSession.cpp:27
ActivateApiOptions
void ActivateApiOptions(Dtk_API *inoutMyApi)
Definition: ActivateApiOptions.cpp:7
PrintUsage
static void PrintUsage(char *executableName)
Definition: mainWithSession.cpp:16
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:151
LaunchAPISampleToParasolidWithSession
int LaunchAPISampleToParasolidWithSession(int argc, char **argv)
Definition: StartAPIToParasolidWithSession.cpp:38
Dtk_API
Definition: dtk_api.hpp:75