Skip to content

Commit d34c3b4

Browse files
committed
Example for IfcOpenShell#209
1 parent 033075f commit d34c3b4

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/examples/IfcOpenHouse.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,17 @@ int main() {
264264
createGroundShape(shape);
265265
IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100.);
266266
file.getSingle<IfcSchema::IfcSite>()->setRepresentation(ground_representation);
267-
267+
268+
// Relate a property set to the IfcSite
269+
const double site_area = IfcGeom::Kernel::face_area(TopoDS::Face(shape)) / 1000 / 1000;
270+
IfcSchema::IfcProperty::list::ptr properties(new IfcSchema::IfcProperty::list);
271+
properties->push(new IfcSchema::IfcPropertySingleValue("TotalArea", null, new IfcSchema::IfcAreaMeasure(site_area), 0));
272+
IfcSchema::IfcPropertySet* pset = new IfcSchema::IfcPropertySet(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), S("Pset_SiteCommon"), null, properties);
273+
IfcSchema::IfcObject::list::ptr related_objs(new IfcSchema::IfcObject::list);
274+
related_objs->push(file.getSingle<IfcSchema::IfcSite>());
275+
IfcSchema::IfcRelDefinesByProperties* site_prop = new IfcSchema::IfcRelDefinesByProperties(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), null, null, related_objs, pset);
276+
file.addEntity(site_prop);
277+
268278
IfcSchema::IfcRepresentation::list::ptr ground_reps = file.getSingle<IfcSchema::IfcSite>()->Representation()->Representations();
269279
for (IfcSchema::IfcRepresentation::list::it it = ground_reps->begin(); it != ground_reps->end(); ++it) {
270280
(*it)->setContextOfItems(file.getRepresentationContext("Model"));

src/ifcgeom/IfcGeom.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ class IFC_GEOM_API Kernel {
215215
gp_Pnt point_above_plane(const gp_Pln& pln, bool agree=true);
216216
const TopoDS_Shape& ensure_fit_for_subtraction(const TopoDS_Shape& shape, TopoDS_Shape& solid);
217217
bool profile_helper(int numVerts, double* verts, int numFillets, int* filletIndices, double* filletRadii, gp_Trsf2d trsf, TopoDS_Shape& face);
218-
double shape_volume(const TopoDS_Shape& s);
219-
double face_area(const TopoDS_Face& f);
220218
void apply_tolerance(TopoDS_Shape& s, double t);
221219
void setValue(GeomValue var, double value);
222220
double getValue(GeomValue var) const;
@@ -228,6 +226,9 @@ class IFC_GEOM_API Kernel {
228226
bool approximate_plane_through_wire(const TopoDS_Wire&, gp_Pln&);
229227
bool flatten_wire(TopoDS_Wire&);
230228

229+
static double shape_volume(const TopoDS_Shape& s);
230+
static double face_area(const TopoDS_Face& f);
231+
231232
static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_Trsf&);
232233
static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_GTrsf&);
233234

0 commit comments

Comments
 (0)