1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use thiserror::Error;
use crate::{
bin::{
Bin,
SpaceLeftBin,
},
corners::Corners,
items::Item,
sortedbin::SortedBin,
};
/// Defines a trait for 3d Bin Packaging algorithments, so is replacing the algorithm possible
pub trait Algorithmen3DBinPackaging
where
Self: Sized,
{
/// A Algorithmen Input where all packages are there
fn create_algorithmen(input: Vec<Item>, bin: Bin) -> Result<Self, AlgorithmenError>;
/// Add Items Later
fn add_item(&mut self, input: Vec<Item>) -> Result<(), AlgorithmenError>;
/// Remove Item
/// If not fit give back items
fn remove_item(&mut self, input: Vec<Item>) -> Result<(), Vec<Item>>;
/// If Space is left
fn space_left(&self) -> u32;
/// Checks if the Items can be in a bin, possible fast check
fn check_fit_quick(input: &[Item], bin: &Bin) -> (bool, SpaceLeftBin);
/// A final result
///
/// the score function checks what the best position is to place a object
///
/// Used default score function
fn calculate(self) -> Result<SortedBin, AlgorithmenError>;
/// A final result
///
/// the score function checks what the best position is to place a object
///
/// In some chasses a custom is preferred
fn calculate_custom<F>(
self,
custom_score_function: Option<F>,
) -> Result<SortedBin, AlgorithmenError>
where
F: Fn(&Bin, &Item, &Corners) -> f32 + Send + Sync;
}
/// Errors for AlgorithmenFirst
#[derive(Debug, Error, PartialEq, Eq, PartialOrd, Ord)]
pub enum AlgorithmenError {
/// Bin has for the packages not enough space left {0}
#[error("Bin has for the packages not enough space left ")]
NotEnoughSpace,
/// No Element was found in the list, should not be possible
#[error("No Element was found in the list, should not be possible")]
NoElementLeft,
/// Item was to big for item
#[error("Item was to big for item")]
ItemToBigForBin,
}