/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #ifndef _EXAMPLE_SCENARIOS_ENGINE_H_ #define _EXAMPLE_SCENARIOS_ENGINE_H_ #include "IfcCore.h" #include "ExSystemServices.h" #include "ExIfcHostAppServices.h" #include "scenario/ScenarioEngineIncludes.h" #include "scenario/ScenarioEngineDeclarations.h" #include "scenario/ScenarioEngineUtils.h" #include "scenario/ScenarioEngineDataHandler.h" #include "scenario/ScenarioEngineInitializer.h" #include "scenario/EngineScenariosForPerfs.h" #include "ExIfcModelFiller.h" #include "Scenarios/ExampleAppServices.h" #include "Scenarios/ExampleScenariosImpl.h" // #define WIN_GDI_MODULE_ENABLE - GDI module in static mode // #define WIN_OPENGL_MODULE_ENABLE - OpenGL module in static mode // #define IFC_GEOM_MODULE_ENABLE - enable geom module in static mode // #define IFC_BREP_BUILDER_MODULE_ENABLE - enable brepbuilder module in static mode // #define IFC_FACET_MODELER_MODULE_ENABLE - enable IfcFacetModeler module in static mode // #define IFC_BREP_MODELER_PE_MODULE_ENABLE - enable IfcBRep { public: OdIfcFilePtr readFile(const OdString& fileName) { OdString path = formatPathToBugDirectory(fileName); if (!odrxSystemServices()->accessFile(path, Oda::kFileRead)) { throw L"File not found"; } return OdExIfcHostAppServices::readFile(path /*, shareMode*/); } virtual OdString findFile(const OdString& filename, OdDbBaseDatabase* pDb = 0, FindFileHint hint = kDefault) { OdString found = OdIfcHostAppServices::findFile(filename, pDb, hint); if (!found.isEmpty()) return found; found = formatPathToBugDirectory(filename); if (!odrxSystemServices()->accessFile(found, Oda::kFileRead)) return OdString::kEmpty; return found; } }; template class FileGeneratorEngineInitializer : public ScenarioEngine::ScenarioEngineInitializer { public: FileGeneratorEngineInitializer() : ScenarioEngine::ScenarioEngineInitializer() { #ifndef _TOOLKIT_IN_DLL_ ODRX_INIT_STATIC_MODULE_MAP(); #endif } virtual ~FileGeneratorEngineInitializer() { IfcProfileBuilder::rxUninit(); IfcRepresentationBuilder::rxUninit(); IfcIndexedPolycurveBuilder::rxUninit(); IfcRailwayBuilder::rxUninit(); IfcAlignmentBuilder::rxUninit(); ::odrxDynamicLinker()->unloadModule(L"IfcCore.dll"); odIfcUninitialize(); } protected: virtual void onServiceInited(FileGeneratorAppServices& serviceInstance) { odIfcInitialize(false, initGeom, modelerType); ::odrxDynamicLinker()->loadModule(L"IfcCore.dll", false); IfcAlignmentBuilder::rxInit(); IfcRailwayBuilder::rxInit(); IfcIndexedPolycurveBuilder::rxInit(); IfcRepresentationBuilder::rxInit(); IfcProfileBuilder::rxInit(); } }; class FileGeneratorDataHandler : public ScenarioEngine::ScenarioDataHandler { public: FileGeneratorDataHandler(ScenarioDef* scenarioDataArray, unsigned int scenarioDataArrayLength) : ScenarioEngine::ScenarioDataHandler(scenarioDataArray, scenarioDataArrayLength) { } virtual int runScenarioImpl(const ScenarioDef& scenarioData, unsigned int runNumber, FileGeneratorAppServices& hostAppService) { if (runNumber > scenarioData.runsNum) { ODA_ASSERT(0); return -1; } OdString extension("ifc"); if (!hostAppService.getBugDirectory().isEmpty()) { hostAppService.setFileName(hostAppService.getBugDirectory() + OdString().format(L"%ls_%i.", scenarioData.testName, runNumber) + extension); } odPrintConsoleString(L"SCENARIO:%ls, run = %d\n", scenarioData.testName, runNumber); int res = ScenarioEngine::TestRun(scenarioData.pf, &hostAppService, runNumber); odPrintConsoleString(L"result = %d\n\n", res); return res; } }; typedef ExampleScenario::ExampleScenarioGetNames FileGeneratorScenarioGetNames; typedef ExampleScenario::ExampleScenarioRunByNumber > FileGeneratorScenarioRunByNumber; typedef ExampleScenario::ExampleScenarioRunByName > FileGeneratorScenarioRunByName; typedef ExampleScenario::ExampleScenarioRunAll > FileGeneratorScenarioRunAll; typedef ExampleScenario::ExampleScenarioRunByNumber > FileGeneratorScenarioRunByNumberWoGeom; typedef ExampleScenario::ExampleScenarioRunByName > FileGeneratorScenarioRunByNameWoGeom; typedef ExampleScenario::ExampleScenarioRunAll > FileGeneratorScenarioRunAllWoGeom; } #endif // _EXAMPLE_SCENARIOS_ENGINE_H_