/////////////////////////////////////////////////////////////////////////////// // 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 "daiUtils/daiUtils.h" #include "ExIfcModelFromBufferTutorial.h" #include "daiRepository.h" ModelFromBufferTutorial::ModelFromBufferTutorial(const OdString& tutorialCommand) : BaseIfcTutorial(tutorialCommand) { m_tutorialArgsParser .add_param( std::make_shared>(m_buffered_model, "buffered_model", ".char array wich contains model")); m_tutorialArgsParser .add_param( std::make_shared>(m_output_path, "output_path", "path to save result of reading model")); //odPrintConsoleString(L"buffered_model - .char array wich contains model\n"); //odPrintConsoleString(L"output_path - path to save result of reading model\n"); } int ModelFromBufferTutorial::run(const MyServices& svcs, const std::vector& argvList, std::ostream& resultStream) { if (BaseIfcTutorial::run(svcs, argvList, resultStream)) { return 1; } if (m_buffered_model.isEmpty()) { m_buffered_model = "ISO-10303-21;" "HEADER;" "FILE_DESCRIPTION((''),'2;1');" "FILE_NAME('','2019-03-20T15:56:41',(''),(''),'BuildingSmart IfcKit by Constructivity','IfcDoc 12.0.0.0','');" "FILE_SCHEMA(('IFC4X3'));" "ENDSEC;" "DATA;" "#1 = IFCPROJECT('1j1i_xK_X5Tf3O1Ox2mOxp',$,'P1','project used for the unit test case',$,'Default project','',(#2),#3);" "#2 = IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.0E-08,#5,#6);" "#3 = IFCUNITASSIGNMENT((#9,#10,#11,#12,#13));" "#5 = IFCAXIS2PLACEMENT3D(#14,#15,#16);" "#6 = IFCDIRECTION((0.,1.));" "#7 = IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Axis','Model',0,$,$,$,#2,$,.MODEL_VIEW.,$);" "#8 = IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Body','Model',0,$,$,$,#2,$,.MODEL_VIEW.,$);" "#9 = IFCSIUNIT($,.LENGTHUNIT.,$,.METRE.);" "#10 = IFCSIUNIT($,.AREAUNIT.,$,.SQUARE_METRE.);" "#11 = IFCSIUNIT($,.VOLUMEUNIT.,$,.CUBIC_METRE.);" "#12 = IFCSIUNIT($,.PLANEANGLEUNIT.,$,.RADIAN.);" "#13 = IFCSIUNIT($,.TIMEUNIT.,$,.SECOND.);" "#14 = IFCCARTESIANPOINT((0.,0.,0.));" "#15 = IFCDIRECTION((0.,0.,1.));" "#16 = IFCDIRECTION((1.,0.,0.));" "#17 = IFCSHAPEREPRESENTATION(#8,'Body','Tessellation',(#18));" "#18 = IFCTRIANGULATEDFACESET(#20,$,.T.,((5,4,6),(1,5,6),(4,5,3),(2,5,1),(3,5,7),(5,2,9),(2,1,10),(1,6,11),(6,4,12),(4,3,8),(7,11,12),(10,11,7),(12,8,7),(9,10,7),(3,7,8),(5,9,7),(2,10,9),(1,11,10),(6,12,11),(4,8,12)),$);" "#19 = IFCPRODUCTDEFINITIONSHAPE($,$,(#17));" "#20 = IFCCARTESIANPOINTLIST3D(((-5.,-8.66025352478027,0.),(5.,-8.66025352478027,0.),(5.,8.66025352478027,0.),(-5.,8.66025352478027,0.),(10.,0.,0.),(-10.,1.22E-15,0.),(10.,0.,-0.300000011920929),(5.,8.66025352478027,-0.300000011920929),(5.,-8.66025352478027,-0.300000011920929),(-5.,-8.66025352478027,-0.300000011920929),(-10.,1.22E-15,-0.300000011920929),(-5.,8.66025352478027,-0.300000011920929)),$);" "#4 = IFCRELAGGREGATES('2uV5ZjLCz2ZO1ngyJeKRdY',$,'Project Container','Project Container for Buildings',#1,(#22));" "#21 = IFCSLAB('35DHdKriP6OQIQhodN2chQ',$,'Slab 1','slab 1 used for the unit test case',$,#23,#19,$,.FLOOR.);" "#23 = IFCLOCALPLACEMENT(#25,#26);" "#25 = IFCLOCALPLACEMENT($,#26);" "#26 = IFCAXIS2PLACEMENT3D(#14,#15,#16);" "#22 = IFCBUILDING('3uvY$5FxrCov51rMJmsbC8',$,'Grasshopper Building','GH Building',$,#25,$,'GH Building',.ELEMENT.,$,$,$);" "#24 = IFCRELCONTAINEDINSPATIALSTRUCTURE('3T9M5M_z521OJsm4kWHgkR',$,'Building','Building Container for Elements',(#21),#22);" "ENDSEC;" "END-ISO-10303-21;"; } auto pSession = oddaiCreateSession(); auto pRepositary = pSession->createRepoFromBuffer(m_buffered_model); auto res = pRepositary->writeFile(m_output_path); oddaiCloseCurrentSession(); return res; }