pub enum UnitKind {
Si {
unit_type: Arc<str>,
name: Arc<str>,
prefix: Option<Arc<str>>,
prefix_exponent: Option<i32>,
},
Conversion {
unit_type: Arc<str>,
name: Option<Arc<str>>,
factor: Option<f64>,
factor_unit: Option<EntityId>,
offset: Option<f64>,
},
Derived {
unit_type: Arc<str>,
elements: Vec<(EntityId, i64)>,
},
Monetary {
currency: Option<Arc<str>>,
},
ContextDependent {
unit_type: Arc<str>,
},
}Expand description
A unit as the file states it.
Variants§
Si
IfcSIUnit: a base SI unit with an optional decimal prefix.
Fields
prefix_exponent: Option<i32>Decimal exponent of the prefix: MILLI is Some(-3), absent is
Some(0), and a prefix that is not an IfcSIPrefix is None.
Exposed as an exponent rather than a factor so callers can apply it exactly instead of multiplying by a rounded 0.001. An unknown prefix is not read as “unprefixed”: that would silently rescale every value in the unit.
Conversion
IfcConversionBasedUnit: a named unit defined by a factor.
Fields
Derived
IfcDerivedUnit: a product of powers of other units.
Fields
Monetary
IfcMonetaryUnit: a currency, with no dimension.
ContextDependent
IfcContextDependentUnit or another named unit form.
Implementations§
Source§impl UnitKind
impl UnitKind
Sourcepub fn unit_type(&self) -> Option<&str>
pub fn unit_type(&self) -> Option<&str>
The IfcUnitEnum this unit declares, when it has one.
IfcMonetaryUnit has none: it is not an IfcNamedUnit.
Sourcepub fn si_scale(&self) -> Option<f64>
pub fn si_scale(&self) -> Option<f64>
Multiplier converting a value in this unit to the unprefixed SI unit.
The prefix is raised to the unit’s power: MILLI SQUARE_METRE gives
1e-6 and MILLI CUBIC_METRE 1e-9. None for an unknown prefix.
Only defined for Si: a conversion-based unit needs its factor unit
resolved too, and a derived unit needs its elements combined, so
neither can answer honestly on its own. crate::exact_unit resolves
all three to the SI base unit.