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
use crate::width_height_depth::WidthHeightDepth;

/// A rectangle that we want to insert into a target bin
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct RectToInsert {
    pub(crate) whd: WidthHeightDepth,
    allow_global_x_axis_rotation: bool,
    allow_global_y_axis_rotation: bool,
    allow_global_z_axis_rotation: bool,
}

impl Into<WidthHeightDepth> for RectToInsert {
    fn into(self) -> WidthHeightDepth {
        WidthHeightDepth {
            width: self.width(),
            height: self.height(),
            depth: self.depth(),
        }
    }
}

#[allow(missing_docs)]
impl RectToInsert {
    pub fn new(width: u32, height: u32, depth: u32) -> Self {
        RectToInsert {
            whd: WidthHeightDepth {
                width,
                height,
                depth,
            },
            // Rotation is not yet supported
            allow_global_x_axis_rotation: false,
            allow_global_y_axis_rotation: false,
            allow_global_z_axis_rotation: false,
        }
    }
}

#[allow(missing_docs)]
impl RectToInsert {
    pub fn width(&self) -> u32 {
        self.whd.width
    }

    pub fn height(&self) -> u32 {
        self.whd.height
    }

    pub fn depth(&self) -> u32 {
        self.whd.depth
    }
}