Reapply skip type bitmap after field reordering changes

This commit is contained in:
Thomas Krijnen
2026-08-09 12:56:15 +02:00
parent b5eca83357
commit dbea3f0362
3 changed files with 34 additions and 15 deletions
+1
View File
@@ -112,6 +112,7 @@ private:
std::vector<bool> types_to_bypass_materialized_;
void initialize_header();
void materialize_bypass_types();
spf_header& ensure_header();
public:
+23 -15
View File
@@ -1938,6 +1938,27 @@ spf_header& ifcopenshell::instance_streamer<Reader>::ensure_header() {
return *owned_header_;
}
template <typename Reader>
void ifcopenshell::instance_streamer<Reader>::materialize_bypass_types() {
if (!schema_) {
return;
}
types_to_bypass_materialized_.assign(schema_->declarations().size(), false);
for (auto& bp : types_to_bypass_) {
std::function<void(const ifcopenshell::entity*)> 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 <typename Reader>
void ifcopenshell::instance_streamer<Reader>::initialize_header() {
storage_.file = owner_;
@@ -1959,21 +1980,7 @@ void ifcopenshell::instance_streamer<Reader>::initialize_header() {
storage_.schema = schema_;
if (schema_) {
types_to_bypass_materialized_.resize(schema_->declarations().size(), false);
for (auto& bp : types_to_bypass_) {
std::function<void(const ifcopenshell::entity*)> 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 <typename Reader>
@@ -2132,6 +2139,7 @@ void ifcopenshell::instance_streamer<Reader>::bypass_types(const std::set<std::s
continue;
}
}
materialize_bypass_types();
}
template <typename Reader>
@@ -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());
}