1use ifc_model::{EntityId, Value};
4
5use crate::error::StyleResult;
6use crate::view::Record;
7
8#[derive(Debug, Clone, Copy)]
10pub struct FillAreaStyle<'m, 's> {
11 record: Record<'m, 's>,
12}
13
14impl<'m, 's> FillAreaStyle<'m, 's> {
15 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
16 Self { record }
17 }
18
19 pub fn name(&self) -> StyleResult<Option<&'m str>> {
21 self.record.optional_text("Name")
22 }
23
24 pub fn fill_styles(&self) -> StyleResult<Vec<EntityId>> {
27 self.record.required_refs_select(
28 "FillStyles",
29 "IfcFillStyleSelect",
30 &[
31 "IfcColour",
32 "IfcExternallyDefinedHatchStyle",
33 "IfcFillAreaStyleHatching",
34 "IfcFillAreaStyleTiles",
35 ],
36 1,
37 None,
38 )
39 }
40
41 pub fn model_or_draughting(&self) -> StyleResult<Option<bool>> {
44 self.record.optional_bool("ModelOrDraughting")
45 }
46}
47
48#[derive(Debug, Clone, Copy)]
50pub struct FillAreaStyleHatching<'m, 's> {
51 record: Record<'m, 's>,
52}
53
54impl<'m, 's> FillAreaStyleHatching<'m, 's> {
55 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
56 Self { record }
57 }
58
59 pub fn hatch_line_appearance(&self) -> StyleResult<EntityId> {
61 self.record
62 .required_ref("HatchLineAppearance", "IfcCurveStyle")
63 }
64
65 pub fn start_of_next_hatch_line(&self) -> StyleResult<&'m Value> {
68 self.record.value("StartOfNextHatchLine")
69 }
70
71 pub fn point_of_reference_hatch_line(&self) -> StyleResult<Option<EntityId>> {
73 self.record
74 .optional_ref("PointOfReferenceHatchLine", "IfcCartesianPoint")
75 }
76
77 pub fn pattern_start(&self) -> StyleResult<Option<EntityId>> {
79 self.record
80 .optional_ref("PatternStart", "IfcCartesianPoint")
81 }
82
83 pub fn hatch_line_angle(&self) -> StyleResult<f64> {
85 self.record.required_number("HatchLineAngle")
86 }
87}
88
89#[derive(Debug, Clone, Copy)]
91pub struct FillAreaStyleTiles<'m, 's> {
92 record: Record<'m, 's>,
93}
94
95impl<'m, 's> FillAreaStyleTiles<'m, 's> {
96 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
97 Self { record }
98 }
99
100 pub fn tiling_pattern(&self) -> StyleResult<Vec<EntityId>> {
102 self.record
103 .required_refs("TilingPattern", "IfcVector", 2, Some(2))
104 }
105}