Fixes to examples · IfcOpenShell/IfcOpenShell@21e53d2 · GitHub
Skip to content

Commit 21e53d2

Browse files
committed
Fixes to examples
1 parent f5d6f4f commit 21e53d2

3 files changed

Lines changed: 35 additions & 24 deletions

File tree

src/examples/IfcAdvancedHouse.cpp

Lines changed: 7 additions & 4 deletions

src/examples/IfcOpenHouse.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,23 @@
2828

2929
#include <Geom_BSplineSurface.hxx>
3030
#include <BRepBuilderAPI_MakeFace.hxx>
31-
3231
#include <Standard_Version.hxx>
3332

33+
#include <BRepGProp.hxx>
34+
#include <GProp_GProps.hxx>
35+
3436
#ifdef USE_IFC4
3537
#include "../ifcparse/Ifc4.h"
38+
#define IfcSchema Ifc4
3639
#else
3740
#include "../ifcparse/Ifc2x3.h"
41+
#define IfcSchema Ifc2x3
3842
#endif
3943

4044
#include "../ifcparse/IfcBaseClass.h"
4145
#include "../ifcparse/IfcHierarchyHelper.h"
4246
#include "../ifcgeom/IfcGeom.h"
47+
#include "../ifcgeom_schema_agnostic/Serialization.h"
4348

4449
#if USE_VLD
4550
#include <vld.h>
@@ -58,7 +63,7 @@ int main() {
5863

5964
// The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several
6065
// convenience functions for working with geometry in IFC files.
61-
IfcHierarchyHelper file;
66+
IfcHierarchyHelper<IfcSchema> file;
6267
file.header().file_name().name("IfcOpenHouse.ifc");
6368

6469
// Start by adding a wall to the file, initially leaving most attributes blank.
@@ -262,11 +267,13 @@ int main() {
262267
// will be tesselated using the deflection specified.
263268
TopoDS_Shape shape;
264269
createGroundShape(shape);
265-
IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100.);
270+
IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(STRINGIFY(IfcSchema), shape, 100.)->as<IfcSchema::IfcProductDefinitionShape>();
266271
file.getSingle<IfcSchema::IfcSite>()->setRepresentation(ground_representation);
267272

268-
// Relate a property set to the IfcSite
269-
const double site_area = IfcGeom::Kernel::face_area(TopoDS::Face(shape)) / 1000 / 1000;
273+
GProp_GProps prop;
274+
BRepGProp::SurfaceProperties(shape, prop);
275+
const double site_area = prop.Mass() / 1000 / 1000;
276+
270277
IfcSchema::IfcProperty::list::ptr properties(new IfcSchema::IfcProperty::list);
271278
properties->push(new IfcSchema::IfcPropertySingleValue("TotalArea", null, new IfcSchema::IfcAreaMeasure(site_area), 0));
272279
IfcSchema::IfcPropertySet* pset = new IfcSchema::IfcPropertySet(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), S("Pset_SiteCommon"), null, properties);
@@ -334,9 +341,9 @@ int main() {
334341
null,
335342
null,
336343
#ifdef USE_IFC4
337-
file.entitiesByType<IfcSchema::IfcWallStandardCase>()->generalize(),
344+
file.instances_by_type<IfcSchema::IfcWallStandardCase>()->generalize(),
338345
#else
339-
file.entitiesByType<IfcSchema::IfcWallStandardCase>()->as<IfcSchema::IfcRoot>(),
346+
file.instances_by_type<IfcSchema::IfcWallStandardCase>()->as<IfcSchema::IfcRoot>(),
340347
#endif
341348
layer_usage);
342349

@@ -391,7 +398,7 @@ int main() {
391398
IfcSchema::IfcShapeRepresentation* door_body = 0;
392399
for (IfcSchema::IfcRepresentation::list::it i = door_representations->begin(); i != door_representations->end(); ++i) {
393400
IfcSchema::IfcRepresentation* rep = *i;
394-
if (rep->is(IfcSchema::Type::IfcShapeRepresentation) && rep->RepresentationIdentifier() == "Body") {
401+
if (rep->declaration().is(IfcSchema::IfcShapeRepresentation::Class()) && rep->RepresentationIdentifier() == "Body") {
395402
door_body = (IfcSchema::IfcShapeRepresentation*) rep;
396403
}
397404
}

src/examples/IfcParseExamples.cpp

Lines changed: 13 additions & 12 deletions

0 commit comments

Comments
 (0)