From d34c3b4b20c65e7856e0ecad649487b950ce45dc Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 25 Apr 2017 16:53:35 +0200 Subject: [PATCH] Example for #209 --- src/examples/IfcOpenHouse.cpp | 12 +++++++++++- src/ifcgeom/IfcGeom.h | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index bd5142ab41..a980c700e7 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -264,7 +264,17 @@ int main() { createGroundShape(shape); IfcSchema::IfcProductDefinitionShape* ground_representation = IfcGeom::tesselate(shape, 100.); file.getSingle()->setRepresentation(ground_representation); - + + // Relate a property set to the IfcSite + const double site_area = IfcGeom::Kernel::face_area(TopoDS::Face(shape)) / 1000 / 1000; + IfcSchema::IfcProperty::list::ptr properties(new IfcSchema::IfcProperty::list); + properties->push(new IfcSchema::IfcPropertySingleValue("TotalArea", null, new IfcSchema::IfcAreaMeasure(site_area), 0)); + IfcSchema::IfcPropertySet* pset = new IfcSchema::IfcPropertySet(guid(), file.getSingle(), S("Pset_SiteCommon"), null, properties); + IfcSchema::IfcObject::list::ptr related_objs(new IfcSchema::IfcObject::list); + related_objs->push(file.getSingle()); + IfcSchema::IfcRelDefinesByProperties* site_prop = new IfcSchema::IfcRelDefinesByProperties(guid(), file.getSingle(), null, null, related_objs, pset); + file.addEntity(site_prop); + IfcSchema::IfcRepresentation::list::ptr ground_reps = file.getSingle()->Representation()->Representations(); for (IfcSchema::IfcRepresentation::list::it it = ground_reps->begin(); it != ground_reps->end(); ++it) { (*it)->setContextOfItems(file.getRepresentationContext("Model")); diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index aecd644e98..56004e838b 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -215,8 +215,6 @@ public: gp_Pnt point_above_plane(const gp_Pln& pln, bool agree=true); const TopoDS_Shape& ensure_fit_for_subtraction(const TopoDS_Shape& shape, TopoDS_Shape& solid); bool profile_helper(int numVerts, double* verts, int numFillets, int* filletIndices, double* filletRadii, gp_Trsf2d trsf, TopoDS_Shape& face); - double shape_volume(const TopoDS_Shape& s); - double face_area(const TopoDS_Face& f); void apply_tolerance(TopoDS_Shape& s, double t); void setValue(GeomValue var, double value); double getValue(GeomValue var) const; @@ -228,6 +226,9 @@ public: bool approximate_plane_through_wire(const TopoDS_Wire&, gp_Pln&); bool flatten_wire(TopoDS_Wire&); + static double shape_volume(const TopoDS_Shape& s); + static double face_area(const TopoDS_Face& f); + static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_Trsf&); static TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_GTrsf&);