retain_rooted_entities

Function retain_rooted_entities 

Source
pub(crate) fn retain_rooted_entities(data_model: &mut DataModel)
Expand description

Keep the entity rows a rooted-only client can need, dropping the rest.

A row is kept when EITHER

  • it is rooted: it carries a GlobalId, or its type is one the schema registry says declares one (an IfcRoot subtype whose GlobalId the file left empty is still an object); or
  • another table of this data model references its id: a material, a material layer set or usage (materials.definition_id / material_id), the RelatingMaterial / RelatingClassification / RelatingDocument of an IfcRelAssociates* row, and so on.

The second rule is what keeps every relation resolvable. Without it the relationships table would name IfcMaterial and IfcClassificationReference ids the entities table no longer describes, and a client resolving a relation’s endpoint to its type or name through the entities table would find nothing. They are few, so keeping them costs nothing measurable; the rows this drops are the ones nothing points at.

entity_ids are untouched, and the kept rows stay in file order.