Skip to main content

ifc_style/fill_style/
resolved.rs

1//! The resolved cut fill of a material, as hatch line families.
2
3use ifc_model::EntityId;
4
5use crate::error::StyleResult;
6
7/// A material's cut fill: one `IfcFillAreaStyle` resolved into hatch lines
8/// in metres and radians (`StyleIndex::material_fill`).
9///
10/// When `model_or_draughting` is `Some(false)` the lengths are draughting
11/// (paper-space) measures, per `IfcFillAreaStyle.ModelorDraughting`; they
12/// are still scaled by the project length unit.
13#[derive(Debug, Clone, PartialEq)]
14#[non_exhaustive]
15pub struct MaterialFill {
16    /// The `IfcFillAreaStyle`.
17    pub style: EntityId,
18    /// The item-less `IfcStyledItem` it was read from; `None` for a bare
19    /// style resolved by `StyleIndex::fill_area_style`.
20    pub styled_item: Option<EntityId>,
21    /// The style's `Name`, when authored.
22    pub name: Option<String>,
23    /// `ModelOrDraughting`; `None` when unauthored or in IFC2X3.
24    pub model_or_draughting: Option<bool>,
25    /// The background colour; alone it is a solid fill (`lines` empty).
26    pub background: Option<[f64; 3]>,
27    /// One family per hatching, in `FillStyles` order as stored.
28    pub lines: Vec<HatchLine>,
29}
30
31/// One `IfcFillAreaStyleHatching` as a family of parallel lines.
32///
33/// The lengths are model measures, or draughting (paper-space) measures when
34/// the owning [`MaterialFill::model_or_draughting`] is `Some(false)`; either
35/// way they are scaled by the project length unit.
36#[derive(Debug, Clone, PartialEq)]
37#[non_exhaustive]
38pub struct HatchLine {
39    /// Angle from the hatching x axis, counter-clockwise, in radians.
40    pub angle_rad: f64,
41    /// Perpendicular distance between neighbouring lines, in metres; positive.
42    pub spacing: f64,
43    /// Offset of each next line along the line direction, in metres; 0 for a length distance.
44    pub shift: f64,
45    /// `PointOfReferenceHatchLine` in metres; `[0, 0]` when absent.
46    pub origin: [f64; 2],
47    /// `PatternStart` in metres, when authored.
48    pub pattern_start: Option<[f64; 2]>,
49    /// `[visible, invisible]` lengths in metres; `Some(vec![])` is the
50    /// `'continuous'` font and `None` states no font.
51    pub dashes: Option<Vec<[f64; 2]>>,
52    /// The line colour, when stated.
53    pub colour: Option<[f64; 3]>,
54    /// The line width in metres, when stated.
55    pub width: Option<f64>,
56}
57
58/// A fill a material states in one representation context
59/// (`StyleIndex::material_fills`).
60#[derive(Debug, Clone, PartialEq)]
61#[non_exhaustive]
62pub struct ContextFill {
63    /// The `IfcStyledRepresentation` the fill was read from (the lowest one
64    /// of the context when several agree).
65    pub representation: EntityId,
66    /// Its `ContextOfItems`.
67    pub context: EntityId,
68    /// The context's `ContextIdentifier`, when authored.
69    pub identifier: Option<String>,
70    /// The context's `ContextType`, when authored.
71    pub context_type: Option<String>,
72    /// `TargetView` of an `IfcGeometricRepresentationSubContext` without the
73    /// dots (`"SECTION_VIEW"`); `None` for any other context.
74    pub target_view: Option<String>,
75    /// `UserDefinedTargetView` of a sub-context, when authored.
76    pub user_defined_target_view: Option<String>,
77    /// `ParentContext` of a sub-context; `None` for any other context.
78    pub parent_context: Option<EntityId>,
79    /// The fill.
80    pub fill: MaterialFill,
81}
82
83/// What a material states in one representation context
84/// (`StyleIndex::material_fills_by_context`): the context, and its fill or
85/// the refusal that belongs to this context alone.
86#[derive(Debug, Clone, PartialEq)]
87#[non_exhaustive]
88pub struct ContextFillResult {
89    /// The lowest `IfcStyledRepresentation` of the material in this context
90    /// that states a fill or was refused.
91    pub representation: EntityId,
92    /// Its `ContextOfItems`.
93    pub context: EntityId,
94    /// The context's `ContextIdentifier`, when authored.
95    pub identifier: Option<String>,
96    /// The context's `ContextType`, when authored.
97    pub context_type: Option<String>,
98    /// `TargetView` of an `IfcGeometricRepresentationSubContext` without the
99    /// dots (`"SECTION_VIEW"`); `None` for any other context.
100    pub target_view: Option<String>,
101    /// `UserDefinedTargetView` of a sub-context, when authored.
102    pub user_defined_target_view: Option<String>,
103    /// `ParentContext` of a sub-context; `None` for any other context.
104    pub parent_context: Option<EntityId>,
105    /// The context's fill, or why this context was refused.
106    pub fill: StyleResult<MaterialFill>,
107}