diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 127393dbbb..afe10afd56 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -47,7 +47,7 @@ void MAKE_INIT_FN(MappingImplementation)(ifcopenshell::geometry::impl::MappingFa #define mapping POSTFIX_SCHEMA(mapping) -IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchema::IfcRepresentation* representation, bool only_direct) { +IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchema::IfcRepresentation* representation, IfcSchema::IfcRepresentationMap*& rmap, bool only_direct) { IfcSchema::IfcProduct::list::ptr products(new IfcSchema::IfcProduct::list); IfcSchema::IfcProductRepresentation::list::ptr prodreps = representation->OfProductRepresentation(); @@ -68,7 +68,10 @@ IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchem IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap(); if (maps->size() == 1) { - IfcSchema::IfcRepresentationMap* rmap = *maps->begin(); + rmap = *maps->begin(); + if (not_reusable_maps_.find(rmap) != not_reusable_maps_.end()) { + return products; + } taxonomy::matrix4::ptr origin = taxonomy::cast(map(rmap->MappingOrigin())); if (origin->is_identity()) { IfcSchema::IfcMappedItem::list::ptr items = rmap->MapUsage(); @@ -164,7 +167,8 @@ aggregate_of_instance::ptr mapping::find_openings(const IfcUtil::IfcBaseEntity* if (auto rep = inst->as()) { // @todo this is essentially only for hybrid kernel trying to guess // when not to use a simple kernel. - auto prods = products_represented_by(rep, true); + IfcSchema::IfcRepresentationMap* rmap; + auto prods = products_represented_by(rep, rmap, true); for (auto& p : *prods) { openings->push(find_openings(p)); } @@ -225,13 +229,17 @@ void mapping::get_representations(std::vector& tasks, int task_index = 0; for (auto representation : *representations) { - IfcSchema::IfcProduct::list::ptr ifcproducts = filter_products(products_represented_by(representation, false), filters); + IfcSchema::IfcRepresentationMap* rmap; + IfcSchema::IfcProduct::list::ptr ifcproducts = filter_products(products_represented_by(representation, rmap, false), filters); if (ifcproducts->size() == 0) { continue; } auto geometry_reuse_ok_for_current_representation_ = reuse_ok_(ifcproducts); + if (!geometry_reuse_ok_for_current_representation_) { + not_reusable_maps_.insert(rmap); + } IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap(); @@ -253,7 +261,7 @@ void mapping::get_representations(std::vector& tasks, IfcSchema::IfcRepresentation* representation_mapped_to_result = representation_mapped_to(representation); if (representation_mapped_to_result) { representation_processed_as_mapped_item = geometry_reuse_ok_for_current_representation_ && ( - ok_mapped_representations->contains(representation_mapped_to_result) || reuse_ok_(products_represented_by(representation_mapped_to_result))); + ok_mapped_representations->contains(representation_mapped_to_result) || reuse_ok_(products_represented_by(representation_mapped_to_result, rmap))); } if (representation_processed_as_mapped_item) { diff --git a/src/ifcgeom/mapping/mapping.h b/src/ifcgeom/mapping/mapping.h index 770bc3aa19..61e8b4d7b6 100644 --- a/src/ifcgeom/mapping/mapping.h +++ b/src/ifcgeom/mapping/mapping.h @@ -40,6 +40,7 @@ namespace geometry { // Set of instances to mark failures that are intended, such as representations not // resulting in any items due to dimensionality filters. std::set failed_on_purpose_; + std::set not_reusable_maps_; template void process_mapping(bool& matched, taxonomy::ptr& item, IfcUtil::IfcBaseInterface const * inst) { @@ -91,7 +92,7 @@ namespace geometry { virtual const IfcUtil::IfcBaseEntity* get_product_type(const IfcUtil::IfcBaseEntity* product_); virtual const IfcUtil::IfcBaseEntity* get_single_material_association(const IfcUtil::IfcBaseEntity* product); IfcSchema::IfcRepresentation* representation_mapped_to(const IfcSchema::IfcRepresentation* representation); - IfcSchema::IfcProduct::list::ptr products_represented_by(const IfcSchema::IfcRepresentation* representation, bool only_direct=false); + IfcSchema::IfcProduct::list::ptr products_represented_by(const IfcSchema::IfcRepresentation* representation, IfcSchema::IfcRepresentationMap*& rmap, bool only_direct=false); bool reuse_ok_(const IfcSchema::IfcProduct::list::ptr& products); IfcUtil::IfcBaseEntity* get_decomposing_entity(const IfcUtil::IfcBaseEntity* product, bool include_openings);