Skip to main content

ifc_style/texture/
vertex.rs

1//! Texture vertices and coordinate lists.
2
3use ifc_model::{EntityId, Value};
4
5use crate::error::StyleResult;
6use crate::view::Record;
7
8/// Borrowed projection of `IfcTextureVertex`: a single 2D texture coordinate.
9#[derive(Debug, Clone, Copy)]
10pub struct TextureVertex<'m, 's> {
11    record: Record<'m, 's>,
12}
13
14impl<'m, 's> TextureVertex<'m, 's> {
15    pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
16        Self { record }
17    }
18
19    /// The entity id of this texture vertex.
20    pub fn id(&self) -> EntityId {
21        self.record.id
22    }
23
24    /// The `Coordinates` attribute: the raw `(s, t)` pair. Mandatory.
25    pub fn coordinates(&self) -> StyleResult<&'m Value> {
26        self.record.value("Coordinates")
27    }
28}
29
30/// Borrowed projection of `IfcTextureVertexList`: an indexed list of texture
31/// coordinates shared across faces via [`crate::IndexedTextureMap`].
32#[derive(Debug, Clone, Copy)]
33pub struct TextureVertexList<'m, 's> {
34    record: Record<'m, 's>,
35}
36
37impl<'m, 's> TextureVertexList<'m, 's> {
38    pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
39        Self { record }
40    }
41
42    /// The entity id of this texture vertex list.
43    pub fn id(&self) -> EntityId {
44        self.record.id
45    }
46
47    /// The `TexCoordsList` attribute: the raw list of `(s, t)` coordinate pairs. Mandatory.
48    pub fn coordinates(&self) -> StyleResult<&'m Value> {
49        self.record.value("TexCoordsList")
50    }
51}