jagua_rs/entities/instances/
strip_packing.rsuse crate::entities::instances::instance_generic::InstanceGeneric;
use crate::entities::item::Item;
use crate::fsize;
use crate::geometry::geo_traits::Shape;
use crate::util::assertions;
#[derive(Debug, Clone)]
pub struct SPInstance {
pub items: Vec<(Item, usize)>,
pub item_area: fsize,
pub strip_height: fsize,
}
impl SPInstance {
pub fn new(items: Vec<(Item, usize)>, strip_height: fsize) -> Self {
assert!(assertions::instance_item_bin_ids_correct(&items, &[]));
let item_area = items
.iter()
.map(|(item, qty)| item.shape.area() * *qty as fsize)
.sum();
Self {
items,
item_area,
strip_height,
}
}
}
impl InstanceGeneric for SPInstance {
fn items(&self) -> &[(Item, usize)] {
&self.items
}
fn item_area(&self) -> fsize {
self.item_area
}
}