binpack_3d/
algorithmen.rs1use thiserror::Error;
2
3use crate::{
4 bin::{
5 Bin,
6 SpaceLeftBin,
7 },
8 corners::Corners,
9 items::Item,
10 sortedbin::SortedBin,
11};
12
13pub trait Algorithmen3DBinPackaging
15where
16 Self: Sized,
17{
18 fn create_algorithmen(input: Vec<Item>, bin: Bin) -> Result<Self, AlgorithmenError>;
20 fn add_item(&mut self, input: Vec<Item>) -> Result<(), AlgorithmenError>;
22 fn remove_item(&mut self, input: Vec<Item>) -> Result<(), Vec<Item>>;
25 fn space_left(&self) -> u32;
27 fn check_fit_quick(input: &[Item], bin: &Bin) -> (bool, SpaceLeftBin);
29 fn calculate(self) -> Result<SortedBin, AlgorithmenError>;
35 fn calculate_custom<F>(
41 self,
42 custom_score_function: Option<F>,
43 ) -> Result<SortedBin, AlgorithmenError>
44 where
45 F: Fn(&Bin, &Item, &Corners) -> f32 + Send + Sync;
46}
47
48#[derive(Debug, Error, PartialEq, Eq, PartialOrd, Ord)]
50pub enum AlgorithmenError {
51 #[error("Bin has for the packages not enough space left ")]
53 NotEnoughSpace,
54 #[error("No Element was found in the list, should not be possible")]
56 NoElementLeft,
57 #[error("Item was to big for item")]
59 ItemToBigForBin,
60}