Fail faster on representation map not suitable for reuse #5672

This commit is contained in:
Thomas Krijnen
2024-12-17 20:58:10 +01:00
parent bd7c19a861
commit d271fd1779
2 changed files with 15 additions and 6 deletions
+13 -5
View File
@@ -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<taxonomy::matrix4>(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<IfcSchema::IfcRepresentation>()) {
// @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<geometry_conversion_task>& 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<geometry_conversion_task>& 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) {