pub struct BinSection { /* private fields */ }
Expand description
A rectangular section within a target bin that takes up one or more layers
Implementations§
Source§impl BinSection
impl BinSection
Source§impl BinSection
impl BinSection
Source§impl BinSection
impl BinSection
Sourcepub fn try_place(
&self,
incoming: &RectToInsert,
container_comparison_fn: &ComparePotentialContainersFn,
heuristic_fn: &BoxSizeHeuristicFn,
) -> Result<(PackedLocation, [BinSection; 3]), BinSectionError>
pub fn try_place( &self, incoming: &RectToInsert, container_comparison_fn: &ComparePotentialContainersFn, heuristic_fn: &BoxSizeHeuristicFn, ) -> Result<(PackedLocation, [BinSection; 3]), BinSectionError>
See if a LayeredRect
can fit inside of this BinSection.
If it can we return the BinSection
s that would be created by placing the LayeredRect
inside of this BinSection
.
Consider the diagram below of a smaller box placed into of a larger one.
The remaining space can be divided into three new sections.
There are several ways to make this division.
You could keep all of the space above the smaller box intact and split up the space behind and to the right of it.
But within that you have a choice between whether the overlapping space goes to right or behind box.
Or you could keep the space to the right and split the top and behind space.
etc.
There are six possible configurations of newly created sections. The configuration to use is decided on based on a a function provided by the consumer.
┌┬───────────────────┬┐
┌─┘│ ┌─┘│
┌─┘ │ ┌─┘ │
┌─┘ │ ┌─┘ │
┌─┘ │ ┌─┘ │
┌─┘ │ ┌─┘ │
┌─┴──────────┼───────┬─┘ │
│ │ │ │
│ │ │ │
│ ┌┬───┴────┬─┐│ │
│ ┌─┘│ ┌─┘ ││ │
│ ┌─┘ │ ┌─┘ ││ │
│ ┌─┘ │ ┌─┘ ├┼───────────┬┘
├─┴──────┤ ─┘ ││ ┌─┘
│ ┌┴─┬───────┬┘│ ┌─┘
│ ┌─┘ │ ┌─┘ │ ┌─┘
│ ┌─┘ │ ┌─┘ │ ┌─┘
│ ┌─┘ │ ┌─┘ │ ┌─┘
└─┴────────┴─┴───────┴─┘
§Note
Written to be readable/maintainable, not to minimize conditional logic, under the (unverified) assumption that a release compilation will inline and dedupe the function calls and conditionals.
Trait Implementations§
Source§impl Clone for BinSection
impl Clone for BinSection
Source§fn clone(&self) -> BinSection
fn clone(&self) -> BinSection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BinSection
impl Debug for BinSection
Source§impl Default for BinSection
impl Default for BinSection
Source§fn default() -> BinSection
fn default() -> BinSection
Source§impl Ord for BinSection
impl Ord for BinSection
Source§fn cmp(&self, other: &BinSection) -> Ordering
fn cmp(&self, other: &BinSection) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for BinSection
impl PartialEq for BinSection
Source§impl PartialOrd for BinSection
impl PartialOrd for BinSection
impl Copy for BinSection
impl Eq for BinSection
impl StructuralPartialEq for BinSection
Auto Trait Implementations§
impl Freeze for BinSection
impl RefUnwindSafe for BinSection
impl Send for BinSection
impl Sync for BinSection
impl Unpin for BinSection
impl UnwindSafe for BinSection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)