/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "OdaCommon.h" #include "RxInit.h" #include "StaticRxObject.h" #include "RxDynamicModule.h" #include "diagnostics.h" #include #include "Common/daiModuleNames.h" #include "Common/examples/daiSimpleProgramOptions.h" #include "ExStepHostAppServices.h" #include "ExStepTutorial_01.h" #include "ExStepTutorial_02.h" #include "ExStepTutorial_03.h" #include "ExStepTutorial_04.h" #include "ExStepTutorial_05.h" #include "ExStepTutorial_06.h" #include "ExStpXTutorial_07.h" #include "ExStepTutorial_08.h" #include "ExStepTutorial_09.h" #include "ExStepTutorial_10_CIS_2_AnalysisModel.h" #include #include #include "ExStepTutorialsCommon.h" #include "ExStepTutorialBase.h" #include "StepCore.h" // // Define module map for statically linked modules: // #if !defined(_TOOLKIT_IN_DLL_) ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdRxThreadPoolService); ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(OdSDAIModule); ODRX_BEGIN_STATIC_MODULE_MAP() ODRX_DEFINE_STATIC_APPMODULE(OdThreadPoolModuleName, OdRxThreadPoolService) ODRX_DEFINE_STATIC_APPMODULE(OdSDAIModuleName, OdSDAIModule) ODRX_END_STATIC_MODULE_MAP() #endif static void customAssertFunc(const char* expression, const char* fileName, int nLineNo) { OdString message; message.format(L"\n!!! Assertion failed: \"%s\"\n file: %ls, line %d\n", OdString(expression).c_str(), OdString(fileName).c_str(), nLineNo); odPrintConsoleString(message); } OdAnsiString StepTutorial::WorkDir::workDir = "./"; StepTutorial::StepTutorialDataCollection tutorialCollection = { REGISTER_TUTORIAL(Tutorial_01), REGISTER_TUTORIAL(Tutorial_02), REGISTER_TUTORIAL(Tutorial_03), REGISTER_TUTORIAL(Tutorial_04), REGISTER_TUTORIAL(Tutorial_05), REGISTER_TUTORIAL(Tutorial_06), REGISTER_TUTORIAL(Tutorial_07), REGISTER_TUTORIAL(Tutorial_08), REGISTER_TUTORIAL(Tutorial_09), REGISTER_TUTORIAL(Tutorial_10), }; int tut_main(int argc, tut_main_char* argv[]) { ::odSetAssertFunc(customAssertFunc); #if defined(TARGET_OS_MAC) && !defined(__MACH__) argc = ccommand(&argv); #endif #ifdef MAKE_PAUSE_ON_START odPrintConsoleString(L"\nYou can attach to process. Press enter to continue\n"); getchar(); #endif setlocale(LC_TIME, ""); // set current user locale (not OD_T("C")), for strftime OdStaticRxObject svcs; odPrintConsoleString(L"\n%s developed using %ls ver %ls\n", StepTutorial::applicationName.c_str(), svcs.product().c_str(), svcs.versionString().c_str()); #if !defined(_TOOLKIT_IN_DLL_) ODRX_INIT_STATIC_MODULE_MAP(); #endif using namespace OdDAI::utils; StepTutorial::WorkDir::setPath(getExeDir(OdAnsiString(StepTutorial::getExecutablePath()))); OdString tutorialParam; argv_parser commandLineParser(StepTutorial::applicationName); commandLineParser.add_param(std::make_shared>(tutorialParam, "tutorial", "tutorial number or name.")); commandLineParser.add_param(std::make_shared("tutorial_parameter_collection", "tutorial parameters collection.")); std::vector argumentList(argv + 1, argv + argc); StepTutorial::ExecutionStreamWrapper executionStream; switch (commandLineParser.parse(argumentList, executionStream)) { case ParseResult::failed: { odPrintConsoleString(L"\nPress ENTER to continue...\n"); return 1; } break; case ParseResult::showHelp: { showTutorialHelp(svcs, tutorialCollection, executionStream); return 0; } break; default: break; } int tutorialNumber = -1; StepTutorial::TutorialExecutor currentTutorial = nullptr; if (OdDAI::utils::tryParse(tutorialParam, tutorialNumber)) { if ((tutorialNumber > 0) && (tutorialCollection.size() > static_cast(tutorialNumber - 1))) { currentTutorial = tutorialCollection[tutorialNumber - 1]->executor; } else { odPrintConsoleString(L"\n\nTutorial wrong number."); showTutorialHelp(svcs, tutorialCollection, executionStream); return -2; } } else { for (auto& data : tutorialCollection) { if (data->name == OdAnsiString(tutorialParam).makeLower()) { currentTutorial = data->executor; break; } } if (currentTutorial == nullptr) { odPrintConsoleString(L"\n\nTutorial wrong name."); showTutorialHelp(svcs, tutorialCollection, executionStream); return -2; } } // Initialize ODA SDK odrxInitialize(&svcs); try { OdRxModulePtr sdai = odrxDynamicLinker()->loadModule("sdai.tx", false); std::vector tutorialArgs(argumentList.begin() + 1, argumentList.end()); switch (currentTutorial(svcs, tutorialArgs, executionStream)) { case StepTutorial::ExecutionResult::eFailed: { return -1; } break; case StepTutorial::ExecutionResult::eWrongParams: { return -2; } break; default: break; } } catch (OdError& e) { odPrintConsoleString(L"\n\nError: %ls", e.description().c_str()); return -1; } // Uninitialize ODA SDK odrxUninitialize(); return 0; }