1use ifc_model::{EntityId, Value};
4
5use crate::error::StyleResult;
6use crate::view::Record;
7
8mod resolve;
9mod resolved;
10
11pub(crate) use resolve::resolve_fill;
12pub use resolved::{ContextFill, ContextFillResult, HatchLine, MaterialFill};
13
14#[derive(Debug, Clone, Copy)]
16pub struct FillAreaStyle<'m, 's> {
17 record: Record<'m, 's>,
18}
19
20impl<'m, 's> FillAreaStyle<'m, 's> {
21 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
22 Self { record }
23 }
24
25 pub fn name(&self) -> StyleResult<Option<&'m str>> {
27 self.record.optional_text("Name")
28 }
29
30 pub fn fill_styles(&self) -> StyleResult<Vec<EntityId>> {
39 self.record.required_refs_select(
40 "FillStyles",
41 "IfcFillStyleSelect",
42 &[
43 "IfcColourSpecification",
46 "IfcPreDefinedColour",
47 "IfcExternallyDefinedHatchStyle",
48 "IfcFillAreaStyleHatching",
49 "IfcFillAreaStyleTiles",
50 ],
51 1,
52 None,
53 )
54 }
55
56 pub fn model_or_draughting(&self) -> StyleResult<Option<bool>> {
59 self.record.optional_bool("ModelOrDraughting")
60 }
61}
62
63#[derive(Debug, Clone, Copy)]
65pub struct FillAreaStyleHatching<'m, 's> {
66 record: Record<'m, 's>,
67}
68
69impl<'m, 's> FillAreaStyleHatching<'m, 's> {
70 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
71 Self { record }
72 }
73
74 pub fn hatch_line_appearance(&self) -> StyleResult<EntityId> {
76 self.record
77 .required_ref("HatchLineAppearance", "IfcCurveStyle")
78 }
79
80 pub fn start_of_next_hatch_line(&self) -> StyleResult<&'m Value> {
83 self.record.value("StartOfNextHatchLine")
84 }
85
86 pub fn point_of_reference_hatch_line(&self) -> StyleResult<Option<EntityId>> {
88 self.record
89 .optional_ref("PointOfReferenceHatchLine", "IfcCartesianPoint")
90 }
91
92 pub fn pattern_start(&self) -> StyleResult<Option<EntityId>> {
94 self.record
95 .optional_ref("PatternStart", "IfcCartesianPoint")
96 }
97
98 pub fn hatch_line_angle(&self) -> StyleResult<f64> {
100 self.record.required_number("HatchLineAngle")
101 }
102}
103
104#[derive(Debug, Clone, Copy)]
106pub struct FillAreaStyleTiles<'m, 's> {
107 record: Record<'m, 's>,
108}
109
110impl<'m, 's> FillAreaStyleTiles<'m, 's> {
111 pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
112 Self { record }
113 }
114
115 pub fn tiling_pattern(&self) -> StyleResult<Vec<EntityId>> {
117 self.record
118 .required_refs("TilingPattern", "IfcVector", 2, Some(2))
119 }
120}