use ifc_model::EntityId;
use crate::error::StyleResult;
use crate::view::Record;
#[derive(Debug, Clone, Copy)]
pub struct PlanarExtent<'m, 's> {
record: Record<'m, 's>,
}
impl<'m, 's> PlanarExtent<'m, 's> {
pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
Self { record }
}
pub fn size_in_x(&self) -> StyleResult<f64> {
self.record.required_number("SizeInX")
}
pub fn size_in_y(&self) -> StyleResult<f64> {
self.record.required_number("SizeInY")
}
}
#[derive(Debug, Clone, Copy)]
pub struct PlanarBox<'m, 's> {
record: Record<'m, 's>,
}
impl<'m, 's> PlanarBox<'m, 's> {
pub(crate) fn from_record(record: Record<'m, 's>) -> Self {
Self { record }
}
#[must_use]
pub fn planar_extent(&self) -> PlanarExtent<'m, 's> {
PlanarExtent::from_record(self.record)
}
pub fn placement(&self) -> StyleResult<EntityId> {
self.record.required_ref_select(
"Placement",
"IfcAxis2Placement",
&["IfcAxis2Placement2D", "IfcAxis2Placement3D"],
)
}
}