diff --git a/src/ifcparse/file.h b/src/ifcparse/file.h index 03d85c7243..b63f755d0f 100644 --- a/src/ifcparse/file.h +++ b/src/ifcparse/file.h @@ -112,6 +112,7 @@ private: std::vector types_to_bypass_materialized_; void initialize_header(); + void materialize_bypass_types(); spf_header& ensure_header(); public: diff --git a/src/ifcparse/parse.cpp b/src/ifcparse/parse.cpp index 680a0e0045..18053da370 100644 --- a/src/ifcparse/parse.cpp +++ b/src/ifcparse/parse.cpp @@ -1938,6 +1938,27 @@ spf_header& ifcopenshell::instance_streamer::ensure_header() { return *owned_header_; } +template +void ifcopenshell::instance_streamer::materialize_bypass_types() { + if (!schema_) { + return; + } + + types_to_bypass_materialized_.assign(schema_->declarations().size(), false); + for (auto& bp : types_to_bypass_) { + std::function mark; + mark = [&](const ifcopenshell::entity* e) { + types_to_bypass_materialized_[e->index_in_schema()] = true; + for (auto& subtype : e->subtypes()) { + mark(subtype); + } + }; + if (auto* e = bp->as_entity()) { + mark(e); + } + } +} + template void ifcopenshell::instance_streamer::initialize_header() { storage_.file = owner_; @@ -1959,21 +1980,7 @@ void ifcopenshell::instance_streamer::initialize_header() { storage_.schema = schema_; - if (schema_) { - types_to_bypass_materialized_.resize(schema_->declarations().size(), false); - for (auto& bp : types_to_bypass_) { - std::function mark; - mark = [&](const ifcopenshell::entity* e) { - types_to_bypass_materialized_[e->index_in_schema()] = true; - for (auto& subtype : e->subtypes()) { - mark(subtype); - } - }; - if (auto* e = bp->as_entity()) { - mark(e); - } - } - } + materialize_bypass_types(); } template @@ -2132,6 +2139,7 @@ void ifcopenshell::instance_streamer::bypass_types(const std::set diff --git a/src/ifcparse/tests/test_ifcopenshell_parse.cpp b/src/ifcparse/tests/test_ifcopenshell_parse.cpp index c15f9dc537..d0f9c0c2ff 100644 --- a/src/ifcparse/tests/test_ifcopenshell_parse.cpp +++ b/src/ifcparse/tests/test_ifcopenshell_parse.cpp @@ -25,3 +25,13 @@ TEST_CASE("IfcPropertySetDefinitionSet references are resolved without replacing CHECK(definitions[0].id() == 136); CHECK(definitions[1].id() == 138); } + +TEST_CASE("Bypassed entity types include their subtypes", "[ifcparse]") { + const std::string fixture = std::string(IFCOPENSHELL_TEST_FIXTURES) + "/ColumnPSetsOfSets.ifc"; + ifcopenshell::file file(ifcopenshell::uninitialized_tag{}); + file.bypass_type("IfcRepresentationItem"); + + REQUIRE(file.initialize(fixture)); + CHECK(file.instances_by_type("IfcRepresentationItem").empty()); + CHECK(file.instances_by_type("IfcCartesianPoint").empty()); +}