use crate::generated::IfcType;
#[derive(Debug, Clone, Copy)]
pub struct LegacyEntityInfo {
pub base_type: IfcType,
pub has_geometry: bool,
}
pub fn get_legacy_entity_info(entity_name: &str) -> Option<LegacyEntityInfo> {
match entity_name {
"IFCPRESENTATIONSTYLEASSIGNMENT" => Some(LegacyEntityInfo {
base_type: IfcType::IfcPresentationStyle,
has_geometry: false,
}),
"IFCBEAMSTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcBeam,
has_geometry: true,
}),
"IFCCOLUMNSTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcColumn,
has_geometry: true,
}),
"IFCMEMBERSTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcMember,
has_geometry: true,
}),
"IFCPLATESTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcPlate,
has_geometry: true,
}),
"IFCSLABSTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcSlab,
has_geometry: true,
}),
"IFCDOORSTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcDoor,
has_geometry: true,
}),
"IFCWINDOWSTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcWindow,
has_geometry: true,
}),
"IFCOPENINGSTANDARDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcOpeningElement,
has_geometry: true,
}),
"IFCSLABELEMENTEDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcSlab,
has_geometry: true,
}),
"IFCWALLELEMENTEDCASE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcWall,
has_geometry: true,
}),
"IFCDOORSTYLE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcDoorType,
has_geometry: false,
}),
"IFCWINDOWSTYLE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcWindowType,
has_geometry: false,
}),
"IFCPROXY" => Some(LegacyEntityInfo {
base_type: IfcType::IfcBuildingElementProxy,
has_geometry: true,
}),
"IFCBUILDINGELEMENT" => Some(LegacyEntityInfo {
base_type: IfcType::IfcBuiltElement,
has_geometry: true,
}),
"IFCBUILDINGELEMENTTYPE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcBuiltElementType,
has_geometry: false,
}),
"IFCEQUIPMENTELEMENT" => Some(LegacyEntityInfo {
base_type: IfcType::IfcDistributionElement,
has_geometry: true,
}),
"IFCELECTRICDISTRIBUTIONPOINT" => Some(LegacyEntityInfo {
base_type: IfcType::IfcFlowController,
has_geometry: true,
}),
"IFCELECTRICALELEMENT" => Some(LegacyEntityInfo {
base_type: IfcType::IfcElement,
has_geometry: true,
}),
"IFCCHAMFEREDGEFEATURE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcFeatureElementSubtraction,
has_geometry: true,
}),
"IFCROUNDEDEDGEFEATURE" => Some(LegacyEntityInfo {
base_type: IfcType::IfcFeatureElementSubtraction,
has_geometry: true,
}),
"IFCSTRUCTURALLINEARACTIONVARYING" => Some(LegacyEntityInfo {
base_type: IfcType::IfcStructuralLinearAction,
has_geometry: true,
}),
"IFCSTRUCTURALPLANARACTIONVARYING" => Some(LegacyEntityInfo {
base_type: IfcType::IfcStructuralPlanarAction,
has_geometry: true,
}),
"IFCSOLIDSTRATUM" => Some(LegacyEntityInfo {
base_type: IfcType::IfcGeotechnicalStratum,
has_geometry: true,
}),
"IFCVOIDSTRATUM" => Some(LegacyEntityInfo {
base_type: IfcType::IfcGeotechnicalStratum,
has_geometry: true,
}),
"IFCWATERSTRATUM" => Some(LegacyEntityInfo {
base_type: IfcType::IfcGeotechnicalStratum,
has_geometry: true,
}),
_ => None,
}
}
pub fn is_legacy_entity(entity_name: &str) -> bool {
get_legacy_entity_info(entity_name).is_some()
}
pub fn map_legacy_to_base_type(entity_name: &str) -> Option<IfcType> {
get_legacy_entity_info(entity_name).map(|info| info.base_type)
}
pub const LEGACY_ENTITY_NAMES: &[&str] = &[
"IFCPRESENTATIONSTYLEASSIGNMENT",
"IFCBEAMSTANDARDCASE",
"IFCCOLUMNSTANDARDCASE",
"IFCMEMBERSTANDARDCASE",
"IFCPLATESTANDARDCASE",
"IFCSLABSTANDARDCASE",
"IFCDOORSTANDARDCASE",
"IFCWINDOWSTANDARDCASE",
"IFCOPENINGSTANDARDCASE",
"IFCSLABELEMENTEDCASE",
"IFCWALLELEMENTEDCASE",
"IFCDOORSTYLE",
"IFCWINDOWSTYLE",
"IFCPROXY",
"IFCBUILDINGELEMENT",
"IFCBUILDINGELEMENTTYPE",
"IFCEQUIPMENTELEMENT",
"IFCELECTRICDISTRIBUTIONPOINT",
"IFCELECTRICALELEMENT",
"IFCCHAMFEREDGEFEATURE",
"IFCROUNDEDEDGEFEATURE",
"IFCSTRUCTURALLINEARACTIONVARYING",
"IFCSTRUCTURALPLANARACTIONVARYING",
"IFCSOLIDSTRATUM",
"IFCVOIDSTRATUM",
"IFCWATERSTRATUM",
];
#[cfg(test)]
mod legacy_entity_name_tests {
use super::*;
#[test]
fn every_listed_name_resolves_as_legacy() {
for &name in LEGACY_ENTITY_NAMES {
assert!(is_legacy_entity(name), "{name} is not a legacy entity");
}
}
}