rectangle_pack/
rect_to_insert.rs

1use crate::width_height_depth::WidthHeightDepth;
2
3/// A rectangle that we want to insert into a target bin
4#[derive(Debug, Copy, Clone, PartialEq)]
5pub struct RectToInsert {
6    pub(crate) whd: WidthHeightDepth,
7    allow_global_x_axis_rotation: bool,
8    allow_global_y_axis_rotation: bool,
9    allow_global_z_axis_rotation: bool,
10}
11
12impl Into<WidthHeightDepth> for RectToInsert {
13    fn into(self) -> WidthHeightDepth {
14        WidthHeightDepth {
15            width: self.width(),
16            height: self.height(),
17            depth: self.depth(),
18        }
19    }
20}
21
22#[allow(missing_docs)]
23impl RectToInsert {
24    pub fn new(width: u32, height: u32, depth: u32) -> Self {
25        RectToInsert {
26            whd: WidthHeightDepth {
27                width,
28                height,
29                depth,
30            },
31            // Rotation is not yet supported
32            allow_global_x_axis_rotation: false,
33            allow_global_y_axis_rotation: false,
34            allow_global_z_axis_rotation: false,
35        }
36    }
37}
38
39#[allow(missing_docs)]
40impl RectToInsert {
41    pub fn width(&self) -> u32 {
42        self.whd.width
43    }
44
45    pub fn height(&self) -> u32 {
46        self.whd.height
47    }
48
49    pub fn depth(&self) -> u32 {
50        self.whd.depth
51    }
52}