pub fn exact_predefined_sets(
model: &Model,
object: EntityId,
entity: &str,
) -> Result<Vec<ExactPredefinedSet>, ExactPropertyError>Expand description
Every predefined property set of entity type entity (or a subtype)
assigned to object, each with all its own attributes resolved.
A door can carry several sets of one type, one
IfcDoorPanelProperties per leaf, which exact_property would refuse
as ambiguous; this lists them all. Occurrence sets come first, then
those of the object’s IfcTypeObject, each in assignment order. No
override is applied between the two sources: every set is reported with
its ExactSource, and which one governs is the caller’s decision (for
example the occurrence’s sets when it has any, else the type’s). An
empty result is a proven absence of such sets. The traversal, model and
assignment validation are those of exact_property, so object may
be a type object (an IfcDoorType, an IFC2X3 IfcDoorStyle), whose own
HasPropertySets are listed with ExactSource::Type of object
(#193).
§Door and window geometry
This is the read path for derived door operation geometry (#148): per
leaf, PanelOperation and PanelPosition come as
ExactValue::Enum, and PanelWidth as an IFCNORMALISEDRATIOMEASURE
fraction of the door’s OverallWidth; LiningDepth and
LiningThickness are lengths in the project length unit, which
exact_unit resolves from their value_type.
use ifc_model::{EntityId, Model};
use ifc_properties::{exact_predefined_sets, exact_unit, ExactValue};
/// (operation, position, width fraction) of each leaf of `door`.
fn leaves(model: &Model, door: EntityId) -> Option<Vec<(String, String, f64)>> {
let panels = exact_predefined_sets(model, door, "IfcDoorPanelProperties").ok()?;
panels
.iter()
.map(|panel| {
let text = |name| match &panel.attribute(name)?.value {
ExactValue::Enum(value) => Some(value.to_string()),
_ => None,
};
let width = match panel.attribute("PanelWidth")?.value {
ExactValue::Real(fraction) => fraction,
_ => return None, // `$`: no width stated
};
Some((text("PanelOperation")?, text("PanelPosition")?, width))
})
.collect()
}
/// The lining depth of `door` in metres.
fn lining_depth(model: &Model, door: EntityId) -> Option<f64> {
let linings = exact_predefined_sets(model, door, "IfcDoorLiningProperties").ok()?;
let depth = linings.first()?.attribute("LiningDepth")?;
let ExactValue::Real(value) = depth.value else { return None };
let unit = exact_unit(model, depth.value_type.as_deref()?, depth.unit_id).ok()?;
Some(value * unit.scale)
}§Errors
ExactPropertyError::NotAPredefinedSet when the declared release does
not declare entity as a predefined property set, and otherwise any
ExactPropertyError of exact_property, including a set attribute
that cannot be read exactly (an aggregate refuses as
ExactPropertyError::UnsupportedDefinition).