ecitygml_core/model/relief/
abstract_relief_component.rs1use crate::model::common::LevelOfDetail;
2use crate::model::core::{
3 AbstractSpaceBoundary, AsAbstractFeature, AsAbstractSpaceBoundary, AsAbstractSpaceBoundaryMut,
4};
5use crate::model::relief::TinRelief;
6use egml::model::geometry::Envelope;
7use nalgebra::Isometry3;
8
9#[derive(Debug, Clone, PartialEq)]
10pub struct AbstractReliefComponent {
11 pub(crate) abstract_space_boundary: AbstractSpaceBoundary,
12 lod: LevelOfDetail,
13}
14
15impl AbstractReliefComponent {
16 pub fn new(abstract_space_boundary: AbstractSpaceBoundary, lod: LevelOfDetail) -> Self {
17 Self {
18 abstract_space_boundary,
19 lod,
20 }
21 }
22}
23
24pub trait AsAbstractReliefComponent: AsAbstractSpaceBoundary {
25 fn abstract_relief_component(&self) -> &AbstractReliefComponent;
26
27 fn lod(&self) -> LevelOfDetail {
28 self.abstract_relief_component().lod
29 }
30}
31
32pub trait AsAbstractReliefComponentMut:
33 AsAbstractSpaceBoundaryMut + AsAbstractReliefComponent
34{
35 fn abstract_relief_component_mut(&mut self) -> &mut AbstractReliefComponent;
36}
37
38impl AsAbstractReliefComponent for AbstractReliefComponent {
39 fn abstract_relief_component(&self) -> &AbstractReliefComponent {
40 self
41 }
42}
43
44impl AsAbstractReliefComponentMut for AbstractReliefComponent {
45 fn abstract_relief_component_mut(&mut self) -> &mut AbstractReliefComponent {
46 self
47 }
48}
49
50#[macro_export]
51macro_rules! impl_abstract_relief_component_traits {
52 ($type:ty) => {
53 $crate::impl_abstract_space_boundary_traits!($type);
54
55 impl $crate::model::core::AsAbstractSpaceBoundary for $type {
56 fn abstract_space_boundary(&self) -> &$crate::model::core::AbstractSpaceBoundary {
57 use $crate::model::relief::AsAbstractReliefComponent;
58 &self.abstract_relief_component().abstract_space_boundary
59 }
60 }
61
62 impl $crate::model::core::AsAbstractSpaceBoundaryMut for $type {
63 fn abstract_space_boundary_mut(
64 &mut self,
65 ) -> &mut $crate::model::core::AbstractSpaceBoundary {
66 use $crate::model::relief::AsAbstractReliefComponentMut;
67 &mut self.abstract_relief_component_mut().abstract_space_boundary
68 }
69 }
70 };
71}
72
73impl_abstract_relief_component_traits!(AbstractReliefComponent);
74
75#[derive(Debug, Clone, PartialEq)]
76pub enum ReliefComponentKind {
77 TinRelief(TinRelief),
78}
79
80impl From<TinRelief> for ReliefComponentKind {
81 fn from(item: TinRelief) -> Self {
82 ReliefComponentKind::TinRelief(item)
83 }
84}
85
86impl ReliefComponentKind {
87 pub fn refresh_bounded_by_recursive(&mut self) {
88 match self {
89 ReliefComponentKind::TinRelief(x) => x.refresh_bounded_by_recursive(),
90 }
91 }
92
93 pub fn apply_transform(&mut self, m: &Isometry3<f64>) {
94 match self {
95 ReliefComponentKind::TinRelief(x) => x.apply_transform(m),
96 }
97 }
98
99 pub fn bounded_by(&self) -> Option<&Envelope> {
100 match self {
101 ReliefComponentKind::TinRelief(x) => x.bounded_by(),
102 }
103 }
104}