IfcGeomIterator: check the filtered products, not unfiltered ones, for reusability. Speeds up things significantly and also fixes geometry reusability in many cases.

This commit is contained in:
Stinkfist0
2018-08-23 10:33:43 +03:00
committed by Thomas Krijnen
parent fbc0215ef1
commit ffa282af9d
+8 -10
View File
@@ -405,18 +405,17 @@ namespace IfcGeom {
for (;;) {
IfcSchema::IfcRepresentation* representation;
// Have we reached the end of our list of representations?
if ( representation_iterator == representations->end() ) {
representations.reset();
return 0;
return 0; // reached the end of our list of representations
}
representation = *representation_iterator;
// Has the list of IfcProducts for this representation been initialized?
if (!ifcproducts) {
// Init. the list of filtered IfcProducts for this representation
ifcproducts = IfcSchema::IfcProduct::list::ptr(new IfcSchema::IfcProduct::list);
IfcSchema::IfcProduct::list::ptr unfiltered_products = kernel.products_represented_by(representation);
// Filter the products based on the set of entities and/or names being included or excluded for processing.
// Include only the desired products for processing.
for (IfcSchema::IfcProduct::list::it jt = unfiltered_products->begin(); jt != unfiltered_products->end(); ++jt) {
IfcSchema::IfcProduct* prod = *jt;
if (boost::all(filters_, filter_match(prod))) {
@@ -429,7 +428,7 @@ namespace IfcGeom {
continue;
}
geometry_reuse_ok_for_current_representation_ = reuse_ok_(unfiltered_products);
geometry_reuse_ok_for_current_representation_ = reuse_ok_(ifcproducts);
IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap();
@@ -447,13 +446,12 @@ namespace IfcGeom {
}
}
// Check if this represenation has (or will be) processed as part its mapped representation
bool representation_processed_as_mapped_item = false;
IfcSchema::IfcRepresentation* representation_mapped_to = kernel.representation_mapped_to(representation);
IfcSchema::IfcRepresentation* representation_mapped_to = kernel.representation_mapped_to(representation);
if (representation_mapped_to) {
// Check if this representation has (or will be) processed as part its mapped representation
representation_processed_as_mapped_item = ok_mapped_representations->contains(representation_mapped_to) ||
reuse_ok_(kernel.products_represented_by(representation_mapped_to));
representation_processed_as_mapped_item = geometry_reuse_ok_for_current_representation_ ||
ok_mapped_representations->contains(representation_mapped_to);
}
if (representation_processed_as_mapped_item) {