Skip to content

Commit 8c19240

Browse files
committed
Don't consider openings as children in geom filters
1 parent dafa304 commit 8c19240

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/ifcgeom/IfcGeom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class IFC_GEOM_API Kernel {
268268

269269
std::pair<std::string, double> initializeUnits(IfcSchema::IfcUnitAssignment*);
270270

271-
static IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*);
271+
static IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*, bool include_openings=true);
272272

273273
static std::map<std::string, IfcSchema::IfcPresentationLayerAssignment*> get_layers(IfcSchema::IfcProduct* prod);
274274

src/ifcgeom/IfcGeomFilter.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ namespace IfcGeom
4242

4343
struct filter
4444
{
45-
filter() : include(false), traverse(false) {}
46-
filter(bool incl, bool trav) : include(incl), traverse(trav) {}
45+
filter() : include(false), traverse(false), traverse_openings(false) {}
46+
filter(bool incl, bool trav, bool trav_openings = false) : include(incl), traverse(trav), traverse_openings(trav_openings) {}
4747
/// Should the product be included (true) or excluded (false).
4848
bool include;
4949
/// If traversal requested, traverse to the parents to see if they satisfy the criteria. E.g. we might be looking for
5050
/// children of a storey named "Level 20", or children of entities that have no representation, e.g. IfcCurtainWall.
5151
bool traverse;
52+
/// Include opening relationships as part of traversal.
53+
bool traverse_openings;
5254
/// Optional description for the filtering criteria of this filter.
5355
std::string description;
5456

@@ -61,10 +63,10 @@ namespace IfcGeom
6163
return is_match == include;
6264
}
6365

64-
static bool traverse_match(IfcSchema::IfcProduct* prod, const filter_t& pred)
66+
bool traverse_match(IfcSchema::IfcProduct* prod, const filter_t& pred) const
6567
{
6668
IfcSchema::IfcProduct* parent, *current = prod;
67-
while ((parent = dynamic_cast<IfcSchema::IfcProduct*>(IfcGeom::Kernel::get_decomposing_entity(current))) != 0) {
69+
while ((parent = dynamic_cast<IfcSchema::IfcProduct*>(IfcGeom::Kernel::get_decomposing_entity(current, traverse_openings))) != 0) {
6870
if (pred(parent)) {
6971
return true;
7072
}
@@ -248,11 +250,9 @@ namespace IfcGeom
248250
struct entity_filter : public filter
249251
{
250252
entity_filter() {}
251-
entity_filter(bool include, bool traverse/*, const std::set<std::string>& types*/)
253+
entity_filter(bool include, bool traverse)
252254
: filter(include, traverse)
253-
{
254-
//populate(types);
255-
}
255+
{}
256256

257257
std::set<IfcSchema::Type::Enum> values;
258258

src/ifcgeom/IfcGeomFunctions.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,33 +1739,33 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representati
17391739
);
17401740
}
17411741

1742-
IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchema::IfcProduct* product) {
1742+
IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchema::IfcProduct* product, bool include_openings) {
17431743
IfcSchema::IfcObjectDefinition* parent = 0;
17441744

17451745
// In case of an opening element, parent to the RelatingBuildingElement
1746-
if ( product->is(IfcSchema::Type::IfcOpeningElement ) ) {
1746+
if (include_openings && product->is(IfcSchema::Type::IfcOpeningElement)) {
17471747
IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)product;
17481748
IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements();
1749-
if ( voids->size() ) {
1749+
if (voids->size()) {
17501750
IfcSchema::IfcRelVoidsElement* ifc_void = *voids->begin();
17511751
parent = ifc_void->RelatingBuildingElement();
17521752
}
1753-
} else if ( product->is(IfcSchema::Type::IfcElement ) ) {
1753+
} else if (product->is(IfcSchema::Type::IfcElement)) {
17541754
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product;
17551755
IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids();
17561756
// In case of a RelatedBuildingElement parent to the opening element
1757-
if ( fills->size() ) {
1758-
for ( IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it ) {
1757+
if (fills->size() && include_openings) {
1758+
for (IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it) {
17591759
IfcSchema::IfcRelFillsElement* fill = *it;
17601760
IfcSchema::IfcObjectDefinition* ifc_objectdef = fill->RelatingOpeningElement();
1761-
if ( product == ifc_objectdef ) continue;
1761+
if (product == ifc_objectdef) continue;
17621762
parent = ifc_objectdef;
17631763
}
17641764
}
17651765
// Else simply parent to the containing structure
17661766
if (!parent) {
17671767
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr parents = element->ContainedInStructure();
1768-
if ( parents->size() ) {
1768+
if (parents->size()) {
17691769
IfcSchema::IfcRelContainedInSpatialStructure* container = *parents->begin();
17701770
parent = container->RelatingStructure();
17711771
}

0 commit comments

Comments
 (0)