use ifc_model::EntityId;
use crate::view::{borrowed_entity, optional_text, required_ref, required_refs, MaterialView};
use crate::MaterialResult;
borrowed_entity!(
MaterialClassificationRelationship,
"IFCMATERIALCLASSIFICATIONRELATIONSHIP"
);
borrowed_entity!(MaterialList, "IFCMATERIALLIST");
borrowed_entity!(MaterialRelationship, "IFCMATERIALRELATIONSHIP");
impl MaterialClassificationRelationship<'_> {
pub fn classification_ids(self) -> MaterialResult<Vec<EntityId>> {
required_refs(
"IFCMATERIALCLASSIFICATIONRELATIONSHIP",
self.id(),
self.entity(),
self.slot("MaterialClassifications")?,
"MaterialClassifications",
1,
)
}
pub fn material_id(self) -> MaterialResult<EntityId> {
required_ref(
"IFCMATERIALCLASSIFICATIONRELATIONSHIP",
self.id(),
self.entity(),
self.slot("ClassifiedMaterial")?,
"ClassifiedMaterial",
)
}
}
impl MaterialList<'_> {
pub fn material_ids(self) -> MaterialResult<Vec<EntityId>> {
required_refs(
"IFCMATERIALLIST",
self.id(),
self.entity(),
self.slot("Materials")?,
"Materials",
1,
)
}
}
impl<'m> MaterialRelationship<'m> {
pub fn name(self) -> MaterialResult<Option<&'m str>> {
optional_text(
"IFCMATERIALRELATIONSHIP",
self.id(),
self.entity(),
self.slot("Name")?,
"Name",
)
}
pub fn description(self) -> MaterialResult<Option<&'m str>> {
optional_text(
"IFCMATERIALRELATIONSHIP",
self.id(),
self.entity(),
self.slot("Description")?,
"Description",
)
}
pub fn relating_material_id(self) -> MaterialResult<EntityId> {
required_ref(
"IFCMATERIALRELATIONSHIP",
self.id(),
self.entity(),
self.slot("RelatingMaterial")?,
"RelatingMaterial",
)
}
pub fn related_material_ids(self) -> MaterialResult<Vec<EntityId>> {
required_refs(
"IFCMATERIALRELATIONSHIP",
self.id(),
self.entity(),
self.slot("RelatedMaterials")?,
"RelatedMaterials",
1,
)
}
pub fn expression(self) -> MaterialResult<Option<&'m str>> {
optional_text(
"IFCMATERIALRELATIONSHIP",
self.id(),
self.entity(),
self.slot("Expression")?,
"Expression",
)
}
}
impl<'m> MaterialView<'m> {
pub fn classification_relationships(
self,
) -> impl Iterator<Item = MaterialClassificationRelationship<'m>> + 'm {
let release = self.release();
self.model()
.of_type("IFCMATERIALCLASSIFICATIONRELATIONSHIP")
.map(move |(id, entity)| {
MaterialClassificationRelationship::from_known(id, entity, release)
})
}
pub fn material_lists(self) -> impl Iterator<Item = MaterialList<'m>> + 'm {
let release = self.release();
self.model()
.of_type("IFCMATERIALLIST")
.map(move |(id, entity)| MaterialList::from_known(id, entity, release))
}
pub fn material_relationships(self) -> impl Iterator<Item = MaterialRelationship<'m>> + 'm {
let release = self.release();
self.model()
.of_type("IFCMATERIALRELATIONSHIP")
.map(move |(id, entity)| MaterialRelationship::from_known(id, entity, release))
}
}