ifc_style/texture/
surface.rs1use ifc_model::{EntityId, Value};
4
5use crate::error::StyleResult;
6use crate::view::Record;
7
8#[derive(Debug, Clone, Copy)]
11pub struct SurfaceTexture<'m, 's> {
12 record: Record<'m, 's>,
13}
14
15impl<'m, 's> SurfaceTexture<'m, 's> {
16 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
17 Self { record }
18 }
19
20 pub fn id(&self) -> EntityId {
22 self.record.id
23 }
24
25 pub fn type_name(&self) -> &'m str {
27 &self.record.entity.type_name
28 }
29
30 pub fn repeat_s(&self) -> StyleResult<bool> {
32 self.record.required_bool("RepeatS")
33 }
34
35 pub fn repeat_t(&self) -> StyleResult<bool> {
37 self.record.required_bool("RepeatT")
38 }
39
40 pub fn mode(&self) -> StyleResult<Option<&'m str>> {
42 self.record.optional_text("Mode")
43 }
44
45 pub fn texture_type(&self) -> StyleResult<Option<&'m str>> {
47 self.record.optional_enum("TextureType")
48 }
49
50 pub fn texture_transform(&self) -> StyleResult<Option<EntityId>> {
52 self.record
53 .optional_ref("TextureTransform", "IfcCartesianTransformationOperator2D")
54 }
55
56 pub fn parameters(&self) -> StyleResult<Option<&'m Value>> {
59 self.record.optional_raw("Parameter")
60 }
61}
62
63#[derive(Debug, Clone, Copy)]
65pub struct BlobTexture<'m, 's> {
66 record: Record<'m, 's>,
67}
68
69impl<'m, 's> BlobTexture<'m, 's> {
70 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
71 Self { record }
72 }
73
74 pub fn surface_texture(&self) -> SurfaceTexture<'m, 's> {
76 SurfaceTexture::from_record(self.record)
77 }
78
79 pub fn raster_format(&self) -> StyleResult<&'m str> {
81 self.record.required_text("RasterFormat")
82 }
83
84 pub fn raster_code(&self) -> StyleResult<&'m Value> {
86 self.record.value("RasterCode")
87 }
88}
89
90#[derive(Debug, Clone, Copy)]
92pub struct PixelTexture<'m, 's> {
93 record: Record<'m, 's>,
94}
95
96impl<'m, 's> PixelTexture<'m, 's> {
97 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
98 Self { record }
99 }
100
101 pub fn width(&self) -> StyleResult<i64> {
103 self.record.required_integer("Width")
104 }
105
106 pub fn height(&self) -> StyleResult<i64> {
108 self.record.required_integer("Height")
109 }
110
111 pub fn colour_components(&self) -> StyleResult<i64> {
113 self.record.required_integer("ColourComponents")
114 }
115
116 pub fn pixel(&self) -> StyleResult<&'m Value> {
118 self.record.value("Pixel")
119 }
120}