Skip to main content

ifc_style/texture/
coordinate.rs

1//! Texture-coordinate generators and mappings.
2
3use ifc_model::{EntityId, Value};
4
5use crate::error::StyleResult;
6use crate::view::Record;
7
8/// Borrowed projection of an `IfcTextureCoordinate` (and its generator/map subtypes):
9/// procedural or explicit texture-coordinate assignment for a mapped item.
10#[derive(Debug, Clone, Copy)]
11pub struct TextureCoordinate<'m, 's> {
12    record: Record<'m, 's>,
13}
14
15impl<'m, 's> TextureCoordinate<'m, 's> {
16    pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
17        Self { record }
18    }
19
20    /// The entity id of this texture coordinate entity.
21    pub fn id(&self) -> EntityId {
22        self.record.id
23    }
24
25    /// The concrete IFC entity type name (e.g. `"IFCTEXTUREMAP"`,
26    /// `"IFCTEXTURECOORDINATEGENERATOR"`).
27    pub fn type_name(&self) -> &'m str {
28        &self.record.entity.type_name
29    }
30
31    /// The `Mode` attribute: the generator/mapping mode name, when authored.
32    pub fn mode(&self) -> StyleResult<Option<&'m str>> {
33        self.record.optional_text("Mode")
34    }
35
36    /// The `Parameter` attribute: mode-specific numeric parameters, when authored.
37    pub fn parameter(&self) -> StyleResult<Option<&'m Value>> {
38        self.record.optional_raw("Parameter")
39    }
40}