Skip to main content

ecitygml_core/model/construction/
window.rs

1use crate::model::common::{ForEachFeatureMut, IterFeatures};
2use crate::model::construction::values::{WindowClassValue, WindowFunctionValue, WindowUsageValue};
3use crate::model::construction::{
4    AbstractFillingElement, AsAbstractFillingElement, AsAbstractFillingElementMut,
5};
6use crate::model::core::refs::AbstractFeatureKindRef;
7use crate::model::core::refs::AbstractFeatureKindRefMut;
8use egml::model::base::Id;
9use egml::model::common::{ApplyTransform, ComputeEnvelope};
10use egml::model::geometry::Envelope;
11use nalgebra::{Isometry3, Rotation3, Scale3, Transform3, Vector3};
12
13#[derive(Debug, Clone, PartialEq)]
14pub struct Window {
15    pub(crate) abstract_filling_element: AbstractFillingElement,
16    class: Option<WindowClassValue>,
17    functions: Vec<WindowFunctionValue>,
18    usages: Vec<WindowUsageValue>,
19}
20
21impl Window {
22    pub fn new(id: Id) -> Self {
23        Self::from_abstract_filling_element(AbstractFillingElement::new(id))
24    }
25
26    pub fn from_abstract_filling_element(abstract_filling_element: AbstractFillingElement) -> Self {
27        Self {
28            abstract_filling_element,
29            class: None,
30            functions: Vec::new(),
31            usages: Vec::new(),
32        }
33    }
34}
35
36impl AsAbstractFillingElement for Window {
37    fn abstract_filling_element(&self) -> &AbstractFillingElement {
38        &self.abstract_filling_element
39    }
40}
41
42impl AsAbstractFillingElementMut for Window {
43    fn abstract_filling_element_mut(&mut self) -> &mut AbstractFillingElement {
44        &mut self.abstract_filling_element
45    }
46}
47
48crate::impl_abstract_filling_element_traits!(Window);
49crate::impl_abstract_filling_element_mut_traits!(Window);
50crate::impl_has_feature_type!(Window, Window);
51
52impl IterFeatures for Window {
53    fn iter_features(&self) -> Box<dyn Iterator<Item = AbstractFeatureKindRef<'_>> + '_> {
54        Box::new(std::iter::once(self.into()).chain(self.abstract_filling_element.iter_features()))
55    }
56}
57
58impl ForEachFeatureMut for Window {
59    fn for_each_feature_mut<F: FnMut(AbstractFeatureKindRefMut<'_>)>(&mut self, f: &mut F) {
60        f((&mut *self).into());
61        self.abstract_filling_element.for_each_feature_mut(f);
62    }
63}
64
65impl ComputeEnvelope for Window {
66    fn compute_envelope(&self) -> Option<Envelope> {
67        self.abstract_filling_element.compute_envelope()
68    }
69}
70
71impl ApplyTransform for Window {
72    fn apply_transform(&mut self, m: Transform3<f64>) {
73        self.abstract_filling_element.apply_transform(m);
74    }
75
76    fn apply_isometry(&mut self, isometry: Isometry3<f64>) {
77        self.abstract_filling_element.apply_isometry(isometry);
78    }
79
80    fn apply_translation(&mut self, vector: Vector3<f64>) {
81        self.abstract_filling_element.apply_translation(vector);
82    }
83
84    fn apply_rotation(&mut self, rotation: Rotation3<f64>) {
85        self.abstract_filling_element.apply_rotation(rotation);
86    }
87
88    fn apply_scale(&mut self, scale: Scale3<f64>) {
89        self.abstract_filling_element.apply_scale(scale);
90    }
91}