Skip to main content

ifc_style/surface_style/
shading.rs

1//! Surface colour and transparency projection.
2
3use ifc_model::EntityId;
4
5use crate::error::StyleResult;
6use crate::view::Record;
7
8/// Borrowed projection of `IfcSurfaceStyleShading` (and its
9/// `IfcSurfaceStyleRendering` subtype, whose extra attributes live in
10/// [`crate::SurfaceStyleRendering`]).
11#[derive(Debug, Clone, Copy)]
12pub struct SurfaceStyleShading<'m, 's> {
13    record: Record<'m, 's>,
14}
15
16impl<'m, 's> SurfaceStyleShading<'m, 's> {
17    pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
18        Self { record }
19    }
20
21    /// The `SurfaceColour` attribute. Mandatory.
22    pub fn surface_colour(&self) -> StyleResult<EntityId> {
23        self.record.required_ref("SurfaceColour", "IfcColourRgb")
24    }
25
26    /// IFC2x3 shading has no transparency slot; that is reported as absent.
27    pub fn transparency(&self) -> StyleResult<Option<f64>> {
28        self.record.optional_normalized("Transparency")
29    }
30}