MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / main

Function main

src/examples/IfcOpenHouse.cpp:60–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58void createGroundShape(TopoDS_Shape& shape);
59
60int main() {
61
62 // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several
63 // convenience functions for working with geometry in IFC files.
64 IfcHierarchyHelper<IfcSchema> file;
65 file.header().file_name()->setname("IfcOpenHouse.ifc");
66
67 // Start by adding a wall to the file, initially leaving most attributes blank.
68 IfcSchema::IfcWallStandardCase* south_wall = new IfcSchema::IfcWallStandardCase(
69 guid(), // GlobalId
70 0, // OwnerHistory
71 "South wall"s, // Name
72 null, // Description
73 null, // ObjectType
74 0, // ObjectPlacement
75 0, // Representation
76 null // Tag
77#ifdef USE_IFC4
78 , IfcSchema::IfcWallTypeEnum::IfcWallType_STANDARD
79#endif
80 );
81 file.addBuildingProduct(south_wall);
82
83 // By adding a wall, a hierarchy has been automatically created that consists of the following
84 // structure: IfcProject > IfcSite > IfcBuilding > IfcBuildingStorey > IfcWall
85
86 // Lateron changing the name of the IfcProject can be done by obtaining a reference to the
87 // project, which has been created automatically.
88 file.getSingle<IfcSchema::IfcProject>()->setName("IfcOpenHouse"s);
89
90 // An IfcOwnerHistory has been initialized as well, which should be assigned to the wall.
91 south_wall->setOwnerHistory(file.getSingle<IfcSchema::IfcOwnerHistory>());
92
93 // The wall will be shaped as a box, with the dimensions specified in millimeters. The resulting
94 // product definition will consist of both a body representation as well as an axis representation
95 // that runs over the centerline of the box in the X-axis.
96 IfcSchema::IfcProductDefinitionShape* south_wall_shape = file.addAxisBox(10000, 360, 3000);
97
98 // Obtain a reference to the placement of the IfcBuildingStorey in order to create a hierarchy
99 // of placements for the products
100 IfcSchema::IfcObjectPlacement* storey_placement = file.getSingle<IfcSchema::IfcBuildingStorey>()->ObjectPlacement();
101
102 // The shape has to be assigned to the representation of the wall and is placed at the origin
103 // of the coordinate system.
104 south_wall->setRepresentation(south_wall_shape);
105 south_wall->setObjectPlacement(file.addLocalPlacement(storey_placement));
106
107 // A pale white colour is assigned to the wall.
108 IfcSchema::IfcPresentationStyleAssignment* wall_colour = setSurfaceColour(file, south_wall_shape, 0.75, 0.73, 0.68);
109
110 // Now create a footing for the wall to rest on.
111 IfcSchema::IfcFooting* footing = new IfcSchema::IfcFooting(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(),
112 "Footing"s, null, null, 0, 0, null, IfcSchema::IfcFootingTypeEnum::IfcFootingType_STRIP_FOOTING);
113
114 file.addBuildingProduct(footing);
115
116 // The footing will span the entire floor plan of our building. The IfcRepresentationContext is
117 // something that has been created automatically as well, but representations could have been

Callers

nothing calls this directly

Calls 15

setSurfaceColourFunction · 0.85
setnameMethod · 0.80
addBuildingProductMethod · 0.80
addAxisBoxMethod · 0.80
addLocalPlacementMethod · 0.80
addBoxMethod · 0.80
addEntityMethod · 0.80
addPlacement3dMethod · 0.80
addMappedItemMethod · 0.80
clipRepresentationMethod · 0.80
addAxisMethod · 0.80

Tested by

no test coverage detected