From dab6e1d220cb736597f0e08413acd69ed91f409a Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 16 Mar 2014 13:35:14 +0000 Subject: [PATCH] Add example file to generate file with IfcCompositeProfileDef and IfcDerivedProfileDef --- src/examples/composite_profile_def.cpp | 119 +++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/examples/composite_profile_def.cpp diff --git a/src/examples/composite_profile_def.cpp b/src/examples/composite_profile_def.cpp new file mode 100644 index 0000000000..fa84c5cb20 --- /dev/null +++ b/src/examples/composite_profile_def.cpp @@ -0,0 +1,119 @@ +/******************************************************************************** + * * + * This file is part of IfcOpenShell. * + * * + * IfcOpenShell is free software: you can redistribute it and/or modify * + * it under the terms of the Lesser GNU General Public License as published by * + * the Free Software Foundation, either version 3.0 of the License, or * + * (at your option) any later version. * + * * + * IfcOpenShell is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * Lesser GNU General Public License for more details. * + * * + * You should have received a copy of the Lesser GNU General Public License * + * along with this program. If not, see . * + * * + ********************************************************************************/ + +/******************************************************************************** + * * + * Example that generates extrusions of parameterized profiles. * + * * + ********************************************************************************/ + +#include +#include +#include + +#include "../ifcparse/Ifc2x3.h" +#include "../ifcparse/IfcUtil.h" +#include "../ifcparse/IfcHierarchyHelper.h" + +typedef std::string S; +typedef IfcWrite::IfcGuidHelper guid; +boost::none_t const null = (static_cast(0)); + +int main(int argc, char** argv) { + const char filename[] = "IfcCompositeProfileDef.ifc"; + IfcHierarchyHelper file; + file.filename(filename); + + double coords1[] = {100.0, 0.0}; + double coords2[] = {200.0, 0.0}; + double coords3[] = {300.0, 0.0}; + + IfcSchema::IfcProfileDef::list profiles (new IfcTemplatedEntityList()); + + IfcSchema::IfcCartesianTransformationOperator2D* transform1 = new IfcSchema::IfcCartesianTransformationOperator2D(file.addDoublet(1, 0), file.addDoublet(0, -1), file.addDoublet(40, 0), null); + IfcSchema::IfcCartesianTransformationOperator2D* transform2 = new IfcSchema::IfcCartesianTransformationOperator2D(file.addDoublet(0, -1), file.addDoublet(1, 0), file.addDoublet(40, 0), 0.3); + + IfcSchema::IfcProfileDef* p1 = new Ifc2x3::IfcIShapeProfileDef( + IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, + null, file.addPlacement2d(), 25.0, 50.0, 5.0, 5.0, 2.0); + + IfcSchema::IfcProfileDef* p2 = new Ifc2x3::IfcLShapeProfileDef( + IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, + null, file.addPlacement2d(), 50.0, 25.0, 5.0, 1.0, 2.0, 2.0, null, null); + + IfcSchema::IfcProfileDef* p3 = new Ifc2x3::IfcTShapeProfileDef( + IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, + null, file.addPlacement2d(), 50.0, 40.0, 10.0, 10.0, 3.0, 2.0, 1.0, 2.0, 2.0, null); + + IfcSchema::IfcProfileDef* p4 = new Ifc2x3::IfcCShapeProfileDef( + IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, + null, file.addPlacement2d(80.), 50.0, 25.0, 5.0, 10.0, 2.0, null); + + file.AddEntity(p2); + file.AddEntity(p3); + + file.AddEntity(transform1); + file.AddEntity(transform2); + + IfcSchema::IfcDerivedProfileDef* p5 = new IfcSchema::IfcDerivedProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, p2, transform1, null); + IfcSchema::IfcDerivedProfileDef* p6 = new IfcSchema::IfcDerivedProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, null, p3, transform2, null); + + profiles->push(p1); + profiles->push(p5); + profiles->push(p6); + profiles->push(p4); + + file.AddEntities(profiles->generalize()); + + IfcSchema::IfcCompositeProfileDef* composite = new IfcSchema::IfcCompositeProfileDef(IfcSchema::IfcProfileTypeEnum::IfcProfileType_AREA, S("IFC"), profiles, null); + + IfcSchema::IfcBuildingElementProxy* product = new IfcSchema::IfcBuildingElementProxy( + guid(), 0, S("profile"), null, null, 0, 0, null, null); + + file.addBuildingProduct(product); + + product->setOwnerHistory(file.getSingle()); + + product->setObjectPlacement(file.addLocalPlacement()); + + IfcSchema::IfcExtrudedAreaSolid* solid = new IfcSchema::IfcExtrudedAreaSolid(composite, + file.addPlacement3d(), file.addTriplet(0, 0, 1), 20.0); + + file.AddEntity(composite); + file.AddEntity(solid); + + IfcSchema::IfcRepresentation::list reps (new IfcTemplatedEntityList()); + IfcSchema::IfcRepresentationItem::list items (new IfcTemplatedEntityList()); + + items->push(solid); + IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation( + file.getSingle(), S("Body"), S("SweptSolid"), items); + reps->push(rep); + + IfcSchema::IfcProductDefinitionShape* shape = new IfcSchema::IfcProductDefinitionShape(0, 0, reps); + file.AddEntity(rep); + file.AddEntity(shape); + + product->setRepresentation(shape); + + file.getSingle()->setName("IfcCompositeProfileDef"); + + std::ofstream f(filename); + f << file; +}