From 8c1924084ac45c61952bead2215e782211a121fd Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 24 Mar 2019 12:36:33 +0100 Subject: [PATCH] Don't consider openings as children in geom filters --- src/ifcgeom/IfcGeom.h | 2 +- src/ifcgeom/IfcGeomFilter.h | 16 ++++++++-------- src/ifcgeom/IfcGeomFunctions.cpp | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index a927e42efd..13dc5acba8 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -268,7 +268,7 @@ public: std::pair initializeUnits(IfcSchema::IfcUnitAssignment*); - static IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*); + static IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*, bool include_openings=true); static std::map get_layers(IfcSchema::IfcProduct* prod); diff --git a/src/ifcgeom/IfcGeomFilter.h b/src/ifcgeom/IfcGeomFilter.h index 4fbeca2726..3d0c431430 100644 --- a/src/ifcgeom/IfcGeomFilter.h +++ b/src/ifcgeom/IfcGeomFilter.h @@ -42,13 +42,15 @@ namespace IfcGeom struct filter { - filter() : include(false), traverse(false) {} - filter(bool incl, bool trav) : include(incl), traverse(trav) {} + filter() : include(false), traverse(false), traverse_openings(false) {} + filter(bool incl, bool trav, bool trav_openings = false) : include(incl), traverse(trav), traverse_openings(trav_openings) {} /// Should the product be included (true) or excluded (false). bool include; /// If traversal requested, traverse to the parents to see if they satisfy the criteria. E.g. we might be looking for /// children of a storey named "Level 20", or children of entities that have no representation, e.g. IfcCurtainWall. bool traverse; + /// Include opening relationships as part of traversal. + bool traverse_openings; /// Optional description for the filtering criteria of this filter. std::string description; @@ -61,10 +63,10 @@ namespace IfcGeom return is_match == include; } - static bool traverse_match(IfcSchema::IfcProduct* prod, const filter_t& pred) + bool traverse_match(IfcSchema::IfcProduct* prod, const filter_t& pred) const { IfcSchema::IfcProduct* parent, *current = prod; - while ((parent = dynamic_cast(IfcGeom::Kernel::get_decomposing_entity(current))) != 0) { + while ((parent = dynamic_cast(IfcGeom::Kernel::get_decomposing_entity(current, traverse_openings))) != 0) { if (pred(parent)) { return true; } @@ -248,11 +250,9 @@ namespace IfcGeom struct entity_filter : public filter { entity_filter() {} - entity_filter(bool include, bool traverse/*, const std::set& types*/) + entity_filter(bool include, bool traverse) : filter(include, traverse) - { - //populate(types); - } + {} std::set values; diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index dc0a98e213..d84052b2a6 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1739,33 +1739,33 @@ IfcGeom::BRepElement

* IfcGeom::Kernel::create_brep_for_processed_representati ); } -IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchema::IfcProduct* product) { +IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchema::IfcProduct* product, bool include_openings) { IfcSchema::IfcObjectDefinition* parent = 0; // In case of an opening element, parent to the RelatingBuildingElement - if ( product->is(IfcSchema::Type::IfcOpeningElement ) ) { + if (include_openings && product->is(IfcSchema::Type::IfcOpeningElement)) { IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)product; IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements(); - if ( voids->size() ) { + if (voids->size()) { IfcSchema::IfcRelVoidsElement* ifc_void = *voids->begin(); parent = ifc_void->RelatingBuildingElement(); } - } else if ( product->is(IfcSchema::Type::IfcElement ) ) { + } else if (product->is(IfcSchema::Type::IfcElement)) { IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product; IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids(); // In case of a RelatedBuildingElement parent to the opening element - if ( fills->size() ) { - for ( IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it ) { + if (fills->size() && include_openings) { + for (IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it) { IfcSchema::IfcRelFillsElement* fill = *it; IfcSchema::IfcObjectDefinition* ifc_objectdef = fill->RelatingOpeningElement(); - if ( product == ifc_objectdef ) continue; + if (product == ifc_objectdef) continue; parent = ifc_objectdef; } } // Else simply parent to the containing structure if (!parent) { IfcSchema::IfcRelContainedInSpatialStructure::list::ptr parents = element->ContainedInStructure(); - if ( parents->size() ) { + if (parents->size()) { IfcSchema::IfcRelContainedInSpatialStructure* container = *parents->begin(); parent = container->RelatingStructure(); }