mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Fail faster on representation map not suitable for reuse #5672
This commit is contained in:
@@ -47,7 +47,7 @@ void MAKE_INIT_FN(MappingImplementation)(ifcopenshell::geometry::impl::MappingFa
|
|||||||
|
|
||||||
#define mapping POSTFIX_SCHEMA(mapping)
|
#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::IfcProduct::list::ptr products(new IfcSchema::IfcProduct::list);
|
||||||
|
|
||||||
IfcSchema::IfcProductRepresentation::list::ptr prodreps = representation->OfProductRepresentation();
|
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();
|
IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap();
|
||||||
if (maps->size() == 1) {
|
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()));
|
taxonomy::matrix4::ptr origin = taxonomy::cast<taxonomy::matrix4>(map(rmap->MappingOrigin()));
|
||||||
if (origin->is_identity()) {
|
if (origin->is_identity()) {
|
||||||
IfcSchema::IfcMappedItem::list::ptr items = rmap->MapUsage();
|
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>()) {
|
if (auto rep = inst->as<IfcSchema::IfcRepresentation>()) {
|
||||||
// @todo this is essentially only for hybrid kernel trying to guess
|
// @todo this is essentially only for hybrid kernel trying to guess
|
||||||
// when not to use a simple kernel.
|
// 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) {
|
for (auto& p : *prods) {
|
||||||
openings->push(find_openings(p));
|
openings->push(find_openings(p));
|
||||||
}
|
}
|
||||||
@@ -225,13 +229,17 @@ void mapping::get_representations(std::vector<geometry_conversion_task>& tasks,
|
|||||||
int task_index = 0;
|
int task_index = 0;
|
||||||
|
|
||||||
for (auto representation : *representations) {
|
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) {
|
if (ifcproducts->size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto geometry_reuse_ok_for_current_representation_ = reuse_ok_(ifcproducts);
|
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();
|
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);
|
IfcSchema::IfcRepresentation* representation_mapped_to_result = representation_mapped_to(representation);
|
||||||
if (representation_mapped_to_result) {
|
if (representation_mapped_to_result) {
|
||||||
representation_processed_as_mapped_item = geometry_reuse_ok_for_current_representation_ && (
|
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) {
|
if (representation_processed_as_mapped_item) {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace geometry {
|
|||||||
// Set of instances to mark failures that are intended, such as representations not
|
// Set of instances to mark failures that are intended, such as representations not
|
||||||
// resulting in any items due to dimensionality filters.
|
// resulting in any items due to dimensionality filters.
|
||||||
std::set<const IfcUtil::IfcBaseInterface*> failed_on_purpose_;
|
std::set<const IfcUtil::IfcBaseInterface*> failed_on_purpose_;
|
||||||
|
std::set<const IfcSchema::IfcRepresentationMap*> not_reusable_maps_;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void process_mapping(bool& matched, taxonomy::ptr& item, IfcUtil::IfcBaseInterface const * inst) {
|
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_product_type(const IfcUtil::IfcBaseEntity* product_);
|
||||||
virtual const IfcUtil::IfcBaseEntity* get_single_material_association(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::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);
|
bool reuse_ok_(const IfcSchema::IfcProduct::list::ptr& products);
|
||||||
IfcUtil::IfcBaseEntity* get_decomposing_entity(const IfcUtil::IfcBaseEntity* product, bool include_openings);
|
IfcUtil::IfcBaseEntity* get_decomposing_entity(const IfcUtil::IfcBaseEntity* product, bool include_openings);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user