From 093ebb2d8f7404ff75ea25902be631a5fe42a488 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 13 Jul 2020 13:19:28 +0200 Subject: [PATCH] Don't try to apply opening elements marked as Reference --- src/ifcgeom/IfcGeomFunctions.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 2e69c242ad..7d06ac4d37 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -1640,11 +1640,12 @@ void IfcGeom::Kernel::sequence_of_point_to_wire(const TColgp_SequenceOfPnt& p, T } IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchema::IfcProduct* product) { - - IfcSchema::IfcRelVoidsElement::list::ptr openings(new IfcSchema::IfcRelVoidsElement::list); + std::vector rs; + if ( product->declaration().is(IfcSchema::IfcElement::Class()) && !product->declaration().is(IfcSchema::IfcOpeningElement::Class()) ) { IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product; - openings = element->HasOpenings(); + auto rels = element->HasOpenings(); + rs.insert(rs.end(), rels->begin(), rels->end()); } // Is the IfcElement a decomposition of an IfcElement with any IfcOpeningElements? @@ -1655,12 +1656,22 @@ IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchem IfcSchema::IfcObjectDefinition* rel_obdef = (*decomposes->begin())->RelatingObject(); if ( rel_obdef->declaration().is(IfcSchema::IfcElement::Class()) && !rel_obdef->declaration().is(IfcSchema::IfcOpeningElement::Class()) ) { IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)rel_obdef; - openings->push(element->HasOpenings()); + auto rels = element->HasOpenings(); + rs.insert(rs.end(), rels->begin(), rels->end()); } obdef = rel_obdef; } + // Filter openings in Reference view, solely marked as Reference. + IfcSchema::IfcRelVoidsElement::list::ptr openings(new IfcSchema::IfcRelVoidsElement::list); + std::for_each(rs.begin(), rs.end(), [&openings](IfcSchema::IfcRelVoidsElement* rel) { + auto reps = rel->RelatedOpeningElement()->Representation()->Representations(); + if (!(reps->size() == 1 && (*reps->begin())->RepresentationIdentifier() == "Reference")) { + openings->push(rel); + } + }); + return openings; }