From fbc0215ef1b437348ec16beaccd46ffdfa9fd808 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Tue, 21 Aug 2018 13:52:09 +0300 Subject: [PATCH] IfcGeomIterator: optimize filtering by performing it prior to geometry reuse inspections. Improves the iteration speed immensely, especially on very large files when only a fraction of the content is wanted to be converted. --- src/ifcgeom/IfcGeomIterator.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index 499f042c48..111f5ae84d 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -416,6 +416,18 @@ namespace IfcGeom { if (!ifcproducts) { 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. + 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))) { + ifcproducts->push(prod); + } + } + + if (ifcproducts->size() == 0) { + _nextShape(); + continue; + } geometry_reuse_ok_for_current_representation_ = reuse_ok_(unfiltered_products); @@ -450,14 +462,6 @@ namespace IfcGeom { continue; } - // Filter the products based on the set of entities and/or names being included or excluded 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))) { - ifcproducts->push(prod); - } - } - ifcproduct_iterator = ifcproducts->begin(); }