/////////////////////////////////////////////////////////////////////////////// // 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 "daiModule.h" #include "daiRepository.h" #include "daiModel.h" #include "daiUtils/daiUtils.h" #include "ExStepHostAppServices.h" #include "ExStepTutorial_02.h" #include "Common/examples/daiSimpleProgramOptions.h" StepTutorial::ExecutionResult Tutorial_02(const ExStepServices&, const std::vector& params, std::ostream& ouputStream) { OdDAI::utils::argv_parser tutorialArgsParser("Tutorial_02"); if (tutorialArgsParser.parse(params, ouputStream) == OdDAI::utils::ParseResult::showHelp) { return StepTutorial::ExecutionResult::eShowHelp; } OdDAI::SessionPtr session = oddaiCreateSession(); OdAnsiString workDir = StepTutorial::WorkDir::getPath(); // Change if needed OdDAI::SchemaPtr scmIFC4X3 = oddaiGetSchema(workDir + "Schemas/IFC4X3_ADD2.exp"); if (!scmIFC4X3.isNull()) { OdDAI::RepositoryPtr repo = session->createRepo("TUTORIAL_02_Repo"); session->openRepo(repo); OdDAI::ModelPtr tutorialModel = repo->createModel("Tutorial_02_Model", scmIFC4X3); if (!tutorialModel.isNull()) { tutorialModel->promoteModelToReadWrite(); OdDAI::Aggr *aggr = nullptr; // // Create IfcCircle // OdDAI::ApplicationInstancePtr cartesianPoint_1 = tutorialModel->createEntityInstance("ifccartesianpoint"); cartesianPoint_1->getAttr("coordinates") >> aggr; OdDAI::ListOfDouble *coordinates = static_cast(aggr); coordinates->createEmpty(); coordinates->addByIndex(0, 0.); coordinates->addByIndex(1, 0.); coordinates->addByIndex(2, 0.); OdDAIObjectId idCartesianPoint_1 = tutorialModel->appendEntityInstance(cartesianPoint_1); OdDAI::ApplicationInstancePtr axis2Placement2d_2 = tutorialModel->createEntityInstance("ifcaxis2placement2d"); axis2Placement2d_2->putAttr("location", idCartesianPoint_1); OdDAIObjectId idAxis2Placement2d_2 = tutorialModel->appendEntityInstance(axis2Placement2d_2); OdDAI::ApplicationInstancePtr circle_3 = tutorialModel->createEntityInstance("ifccircle"); circle_3->putAttr("position", idAxis2Placement2d_2); circle_3->putAttr("radius", 10.); tutorialModel->appendEntityInstance(circle_3); // // Create polyline // OdDAI::ApplicationInstancePtr cartesianPoint_4 = tutorialModel->createEntityInstance("ifccartesianpoint"); cartesianPoint_4->getAttr("coordinates") >> aggr; coordinates = static_cast(aggr); coordinates->createEmpty(); coordinates->addByIndex(0, 10.); coordinates->addByIndex(1, 0.); coordinates->addByIndex(2, 0.); OdDAIObjectId idCartesianPoint_4 = tutorialModel->appendEntityInstance(cartesianPoint_4); OdDAI::ApplicationInstancePtr cartesianPoint_5 = tutorialModel->createEntityInstance("ifccartesianpoint"); cartesianPoint_5->getAttr("coordinates") >> aggr; coordinates = static_cast(aggr); coordinates->createEmpty(); coordinates->addByIndex(0, 30.); coordinates->addByIndex(1, 0.); coordinates->addByIndex(2, 0.); OdDAIObjectId idCartesianPoint_5 = tutorialModel->appendEntityInstance(cartesianPoint_5); OdDAI::ApplicationInstancePtr polyline_6 = tutorialModel->createEntityInstance("ifcpolyline"); polyline_6->getAttr("points") >> aggr; OdDAI::ListOfOdDAIObjectId *points = static_cast(aggr); points->createEmpty(); points->putByIndex(0, idCartesianPoint_4); points->putByIndex(1, idCartesianPoint_5); OdDAIObjectId idPolyline_6 = tutorialModel->appendEntityInstance(polyline_6); } if (repo->writeFile(workDir + "Tutorial_02.ifc") == eOk) { OdDAI::RepositoryPtr repoLoaded = session->createRepoFromFile(workDir + "Tutorial_02.ifc"); OdDAI::ModelPtr loadedModel = repoLoaded->getModel(); auto curves = loadedModel->getEntityExtent("ifccurve"); auto it = curves->createConstIterator(); for (it->beginning(); it->next();) { OdDAIObjectId id; it->getCurrentMember() >> id; if (id.isValid()) { OdDAI::ApplicationInstancePtr curve = id.openObject(); int dim = 0; curve->getAttr("dim") >> dim; // Derived attribute evaluation OdAnsiString stepLine = OdDAI::Utils::getStepLine(curve); odPrintConsoleString(L"\n%hs, DERIVED: dim = %d", stepLine.c_str(), dim); } } repoLoaded->writeFile(workDir + "Tutorial_02_resaved.ifc"); } //repo->deleteModel(tutorialModel); session->closeRepo(repo); odPrintConsoleString(L"\n"); } oddaiCloseCurrentSession(); return StepTutorial::ExecutionResult::eSucceed; }