diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 9867683cf8..73f05196cd 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -156,8 +156,8 @@ aggregate_of_instance::ptr mapping::find_openings(const IfcUtil::IfcBaseEntity* auto product = inst->as(); aggregate_of_instance::ptr openings(new aggregate_of_instance); - if (product->declaration().is(IfcSchema::IfcElement::Class()) && !product->declaration().is(IfcSchema::IfcOpeningElement::Class())) { - IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product; + if (product->as() && !product->as()) { + const IfcSchema::IfcElement* element = product->as(); auto rels = element->HasOpenings(); for (auto& rel : *rels) { openings->push(rel->RelatedOpeningElement()); @@ -170,8 +170,8 @@ aggregate_of_instance::ptr mapping::find_openings(const IfcUtil::IfcBaseEntity* auto decomposes = obdef->Decomposes()->generalize(); if (decomposes->size() != 1) break; IfcSchema::IfcObjectDefinition* rel_obdef = (*decomposes->begin())->as()->RelatingObject(); - if (rel_obdef->declaration().is(IfcSchema::IfcElement::Class()) && !rel_obdef->declaration().is(IfcSchema::IfcOpeningElement::Class())) { - IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)rel_obdef; + if (rel_obdef->as() && !rel_obdef->as()) { + IfcSchema::IfcElement* element = rel_obdef->as(); auto rels = element->HasOpenings(); for (auto& rel : *rels) { openings->push(rel->RelatedOpeningElement());