ifc_lite_processing/data_model/rows/
support.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! Pass-1 bookkeeping and schema probing for the row stream.
6
7use ifc_lite_core::IfcType;
8
9/// An `IfcTypeProduct` (e.g. `IfcBoilerType`) that carries its own
10/// `RepresentationMaps` — a #957 "Route B" mesh candidate. The geometry pass
11/// meshes the ORPHAN ones (no occurrence instantiates them) under the type's own
12/// expressId; without a matching [`EntityRow`] those GLB nodes render with no
13/// attributes (#1518). Everything needed to emit that row is captured here in the
14/// pass-1 scan so the emission phase never re-decodes the type.
15pub(super) struct TypeProductCandidate {
16    pub(super) express_id: u32,
17    pub(super) ifc_type: IfcType,
18    /// The raw STEP keyword (e.g. `"IFCDOORSTYLE"`), kept ONLY so a later
19    /// `render_attributes` call can look up a legacy entity's own attribute
20    /// names (#4203) — `ifc_type` above is already legacy-aware-resolved
21    /// (`IfcDoorType`, not `Unknown`) and is what every other consumer of
22    /// this candidate wants.
23    pub(super) type_name: String,
24    pub(super) global_id: Option<String>,
25    pub(super) name: Option<String>,
26    pub(super) description: Option<String>,
27    /// `IfcTypeProduct.RepresentationMaps` (attr 6) — non-empty by construction.
28    pub(super) rep_map_ids: Vec<u32>,
29    /// `IfcTypeObject.HasPropertySets` (attr 5): the type's directly-attached
30    /// property/quantity set definitions (types do NOT use
31    /// `IfcRelDefinesByProperties`).
32    pub(super) pset_def_ids: Vec<u32>,
33}
34
35/// The first declared `FILE_SCHEMA` entry that has a bundled attribute
36/// registry, or `None`. Attribute positions are schema-specific, so a reader
37/// of attributes by name must fail closed here rather than take the IFC4
38/// layout. The attribute export and the rebar schedule both resolve through
39/// this, so they agree (#7681).
40pub fn attribute_schema(content: &[u8]) -> Option<String> {
41    ifc_lite_core::parser::header::declared_schemas(content).into_iter().find(|schema| {
42        // IfcProject exists in every bundled registry, so this is a schema
43        // recognition probe rather than an entity-specific fallback.
44        ifc_lite_core::attribute_names_for_schema(schema, "IFCPROJECT").is_some()
45    })
46}