From 361f6997a677ed392b3549ee490e325dee9350c5 Mon Sep 17 00:00:00 2001 From: Chinedu Francis Nwafili Date: Mon, 9 Mar 2020 17:59:12 -0400 Subject: [PATCH] Expose methods on PackedLocation --- Cargo.toml | 2 +- src/lib.rs | 21 ++----------------- src/packed_location.rs | 47 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 src/packed_location.rs diff --git a/Cargo.toml b/Cargo.toml index 80ab1d8..aa58dd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rectangle-pack" -version = "0.1.2" +version = "0.1.3" authors = ["Chinedu Francis Nwafili "] edition = "2018" keywords = ["texture", "atlas", "bin", "box", "packer"] diff --git a/src/lib.rs b/src/lib.rs index 527b4d8..7560c96 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,10 +17,12 @@ use crate::width_height_depth::WidthHeightDepth; pub use self::box_size_heuristics::{volume_heuristic, BoxSizeHeuristicFn}; pub use self::rect_to_insert::RectToInsert; +pub use crate::packed_location::PackedLocation; mod bin_section; mod grouped_rects_to_place; +mod packed_location; mod rect_to_insert; mod target_bin; mod width_height_depth; @@ -261,25 +263,6 @@ fn sort_groups_largest_to_smallest( }); } -/// Describes how and where an incoming rectangle was packed into the target bins -#[derive(Debug, PartialEq)] -pub struct PackedLocation { - x: u32, - y: u32, - z: u32, - whd: WidthHeightDepth, - x_axis_rotation: RotatedBy, - y_axis_rotation: RotatedBy, - z_axis_rotation: RotatedBy, -} - -#[derive(Debug, PartialEq)] -#[allow(unused)] // TODO: Implement rotations -enum RotatedBy { - ZeroDegrees, - NinetyDegrees, -} - #[cfg(test)] mod tests { use std::collections::HashMap; diff --git a/src/packed_location.rs b/src/packed_location.rs new file mode 100644 index 0000000..b7215d8 --- /dev/null +++ b/src/packed_location.rs @@ -0,0 +1,47 @@ +use crate::width_height_depth::WidthHeightDepth; + +/// Describes how and where an incoming rectangle was packed into the target bins +#[derive(Debug, PartialEq)] +pub struct PackedLocation { + x: u32, + y: u32, + z: u32, + whd: WidthHeightDepth, + x_axis_rotation: RotatedBy, + y_axis_rotation: RotatedBy, + z_axis_rotation: RotatedBy, +} + +#[derive(Debug, PartialEq)] +#[allow(unused)] // TODO: Implement rotations +enum RotatedBy { + ZeroDegrees, + NinetyDegrees, +} + +#[allow(missing_docs)] +impl PackedLocation { + pub fn x(&self) -> u32 { + self.x + } + + pub fn y(&self) -> u32 { + self.y + } + + pub fn z(&self) -> u32 { + self.z + } + + pub fn width(&self) -> u32 { + self.whd.width + } + + pub fn height(&self) -> u32 { + self.whd.height + } + + pub fn depth(&self) -> u32 { + self.whd.depth + } +}