use std::fmt;
use crate::{Aabb, Vec3};
#[derive(Debug, Clone, PartialEq)]
pub struct SemanticLevel {
index: i32,
label: String,
position: Vec3,
aabb: Aabb,
region_indices: Vec<usize>,
object_indices: Vec<usize>,
}
impl SemanticLevel {
#[must_use]
pub(crate) const fn new(index: i32, label: String, position: Vec3, aabb: Aabb) -> Self {
Self {
index,
label,
position,
aabb,
region_indices: Vec::new(),
object_indices: Vec::new(),
}
}
#[must_use]
pub fn id(&self) -> String {
self.index.to_string()
}
#[must_use]
pub const fn index(&self) -> i32 {
self.index
}
#[must_use]
pub fn label(&self) -> &str {
&self.label
}
#[must_use]
pub const fn position(&self) -> Vec3 {
self.position
}
#[must_use]
pub const fn aabb(&self) -> &Aabb {
&self.aabb
}
#[must_use]
pub fn region_indices(&self) -> &[usize] {
&self.region_indices
}
#[must_use]
pub fn object_indices(&self) -> &[usize] {
&self.object_indices
}
pub(crate) fn add_region(&mut self, region_index: usize) {
self.region_indices.push(region_index);
}
pub(crate) fn add_object(&mut self, object_index: usize) {
self.object_indices.push(object_index);
}
}
impl fmt::Display for SemanticLevel {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
formatter,
"level {}: regions={}, objects={}, bounds=[{}]",
self.index,
self.region_indices.len(),
self.object_indices.len(),
self.aabb
)
}
}