ifc_geometry/error/
about.rs1use ifc_model::EntityId;
4
5use super::GeometryError;
6
7impl GeometryError {
8 pub fn entity(&self) -> Option<EntityId> {
13 match self {
14 Self::MissingEntity { referrer, .. } => Some(*referrer),
15 Self::MissingAttribute { entity, .. }
16 | Self::WrongValueKind { entity, .. }
17 | Self::WrongEntityType { entity, .. }
18 | Self::Unsupported { entity, .. }
19 | Self::CyclicChain { entity, .. }
20 | Self::ChainTooDeep { entity, .. }
21 | Self::AggregateTooLarge { entity, .. }
22 | Self::Degenerate { entity, .. } => Some(*entity),
23 Self::GridAxesParallel { intersection, .. }
24 | Self::GridAxesDoNotIntersect { intersection, .. }
25 | Self::GridAxesInDifferentGrids { intersection, .. } => Some(*intersection),
26 Self::GridAxisWithoutGrid { axis } => Some(*axis),
27 Self::PlacementRelToConflict { placement, .. } => Some(*placement),
28 #[cfg(feature = "compile")]
29 Self::CompilationRefused { entity, .. } => Some(*entity),
30 #[cfg(feature = "compile")]
31 Self::NotASolid { entity, .. } => Some(*entity),
32 #[cfg(feature = "compile")]
33 Self::CachedPlacementMismatch { placement, .. } => Some(*placement),
34 #[cfg(feature = "compile")]
35 Self::SeamSideUnsupported { placement, .. } => Some(*placement),
36 #[cfg(feature = "compile")]
37 Self::CurvePathUnsupported { placement, .. } => Some(*placement),
38 #[cfg(feature = "compile")]
39 Self::PathPieceLengthUnstated { placement, .. }
40 | Self::CurvePathOpenEndUnsupported { placement, .. }
41 | Self::PathPointOffCurve { placement, .. }
42 | Self::PathPointAmbiguous { placement, .. }
43 | Self::CurvePathBoundUnsupported { placement, .. }
44 | Self::PathJointDistancesUnsupported { placement, .. }
45 | Self::PlacementSeamWindowRefused { placement, .. } => Some(*placement),
46 #[cfg(feature = "compile")]
47 Self::StationSeamWindowRefused {
48 product, stations, ..
49 } => Some(stations.first().copied().unwrap_or(*product)),
50 #[cfg(feature = "compile")]
51 Self::RunSeamWindowRefused { product, runs, .. } => {
52 Some(runs.first().copied().unwrap_or(*product))
53 }
54 Self::OpeningNotSubtracted { opening, .. } => Some(*opening),
56 Self::LayerNotSplit { product, .. } => Some(*product),
57 Self::LengthUnitUndeclared {
58 project,
59 assignment,
60 } => assignment.or(*project),
61 Self::AngleUnitUndeclared { entity } => Some(*entity),
62 Self::UnitUnreadable { unit, .. } => Some(*unit),
63 Self::UnitsAmbiguous { second, .. } => Some(*second),
64 Self::UnitRecordDamaged { entity, .. } => Some(*entity),
65 Self::Units(_)
66 | Self::UnitsIncomplete { .. }
67 | Self::InvalidAuthoredValue { .. }
68 | Self::AuthoringSchemaUnbound { .. }
69 | Self::AuthoringEntityNotInSchema { .. } => None,
70 }
71 }
72
73 pub fn is_unsupported(&self) -> bool {
78 match self {
79 Self::Unsupported { .. } => true,
80 #[cfg(feature = "compile")]
82 Self::SeamSideUnsupported { .. } => true,
83 #[cfg(feature = "compile")]
85 Self::CurvePathUnsupported { .. } => true,
86 #[cfg(feature = "compile")]
91 Self::PathPieceLengthUnstated { .. }
92 | Self::CurvePathOpenEndUnsupported { .. }
93 | Self::CurvePathBoundUnsupported { .. }
94 | Self::PathJointDistancesUnsupported { .. } => true,
95 #[cfg(feature = "compile")]
99 Self::StationSeamWindowRefused { refusal, .. }
100 | Self::PlacementSeamWindowRefused { refusal, .. }
101 | Self::RunSeamWindowRefused { refusal, .. } => matches!(
102 refusal,
103 crate::compile::SeamWindowRefusal::UncertifiedLength
104 | crate::compile::SeamWindowRefusal::CertificationBudgetExceeded
105 ),
106 Self::OpeningNotSubtracted { cause, .. } | Self::LayerNotSplit { cause, .. } => {
108 cause.is_unsupported()
109 }
110 _ => false,
111 }
112 }
113}